orElse

inline fun <A> Option<A>.orElse(alternative: () -> Option<A>): Option<A>(source)

Returns this option's if the option is nonempty, otherwise returns another option provided lazily by default.

Parameters

alternative

the default option if this is empty.


inline fun <E, A> Validated<E, A>.orElse(default: () -> Validated<E, A>): Validated<E, A>(source)

Return this if it is Valid, or else fall back to the given default. The functionality is similar to that of findValid except for failure accumulation, where here only the error on the right is preserved and the error on the left is ignored.