either

fnCommonType!(T, Ts) either(alias pred = a => a, T, Ts...)(T first, lazy Ts alternatives) if (alternatives.length >= 1 && !is(CommonType!(T, Ts) == void) && allSatisfy!(ifTestable, T, Ts))

Get the _first argument a that passes an if (unaryFun!pred(a)) test. If no argument passes the test, return the last argument.

Similar to behaviour of the or operator in dynamic languages such as Lisp's (or ...) and Python's a or b or ... except that the last argument is returned upon no match.

Simplifies logic, for instance, in parsing rules where a set of alternative matchers are tried. The _first one that matches returns it match result, typically as an abstract syntax tree (AST).

Bugs

Lazy parameters are currently, too restrictively, inferred by DMD to

always throw even though they don't need to be. This makes it impossible to currently mark either as nothrow. See issue at Bugzilla 12647.

Returns

The _first argument that passes the test pred.