the_one multimethod

Methods

the_one(e:Eachable1, pattern:Any=method, body:Fun=method, found_more:Fun=method, found_none:Fun=method) Source: stdlib.ngs:698
Find the only element that matches the pattern and execute given code with the value

Parameters

bodyThe code to execute when exactly one element that matches the pattern was found. Executed with the found value. It's value will be returned as result of the_one().
found_moreThe code to execute when more than one element matches the pattern. It's value will be returned as result of the_one(). Defaults to function returning null.
found_noneThe code to execute when none of the elements match the pattern. 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]
}
the_one(e:Eachable1, pattern:Any=method) Source: stdlib.ngs:724
Throws ElementNotFound exception if there are no elements that match the pattern or if there is more than one element that matches the pattern.

Parameters

patterndefaults to Any, allowing my_arr.the_one()

Returns

The only element that matches the pattern.