the_one multimethod

Methods

the_one(e:Eachable1, predicate:Any) Source: stdlib.ngs:405
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:430
Find the only element that satisfies the predicate and execute given code with the value

Parameters

bodyThe 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_moreThe 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_noneThe 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]
}
the_one(e:Eachable1) Source: stdlib.ngs:456
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=..., ...}