monadic
monadic copied to clipboard
Evaluate a "or" value lazily.
Sometime we want to evaluate a value of "or"'s parameter. For example, the value should be a newly created object, but if Nothing.or(...) is called, we don't want to create the object. Because the current implemented "or" method is not lazily evaluated, we have to use "if-then" statement in such a case. In scala, a parameter of the "orElse" method is evaluated lazily. This commit contains a new method "or_lazy" which evaluate the value lazily.