Methods

the_oneΒΆ

the_one(something:Eachable1, predicate:Any, body:Fun, found_more:Fun=(a function), found_none:Fun=(a function))

Find the only element that satisfies the predicate and execute given code with the value
Source: stdlib.ngs:255

body

The code to execute when exactly one element that satisfies the predicate was found. Executed with the found value. It's value will be returned as result of the_one().

found_more

The code to execute when more than one element satisfies the predicate. It's value will be returned as result of the_one(). Defaults to function returning null.

found_none

The code to execute when none of the elements satisfy the predicate. It's value will be returned as result of the_one(). Defaults to function returning null.

Returns

Result of running on of the following: body, found_more, found_none

Example

F name(dn:MethodDocNode) {
	dn.children.the_one(MethodNameDocNode).text[0]
}