the_one multimethod
Methods
- the_one(e:Eachable1, predicate:Any) Source: stdlib.ngs:383
Find the only element that satisfies the predicate. Throws ElementNotFound exception if there are no elements that satisfy the predicate or if there is more than one element that satisfies the predicate. Returns
The only element that satisfies the predicate.
- the_one(e:Eachable1, predicate:Any, body:Fun, found_more:Fun=method, found_none:Fun=method) Source: stdlib.ngs:408
Find the only element that satisfies the predicate and execute given code with the value Parameters
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_noneExample
F name(dn:MethodDocNode) { dn.children.the_one(MethodNameDocNode).text[0] }
- the_one(e:Eachable1) Source: stdlib.ngs:434
Extract the only element. Throws ElementNotFound exception if there are no elements or if there is more than one element. Returns
The only element.Example
``aws ec2 describe-security-groups --group-ids $sg_id``.the_one() # {OwnerId=..., VpcId=..., GroupId=..., ...}