Executes the provided block of code conditionally based on the given boolean predicate. If the predicate is true, the block of code is executed and its result is returned. If the predicate is false, None is returned. whenever is to when as flatMap is to map.
Executes the provided block of code conditionally based on the given boolean predicate. If the predicate is true, the block of code is executed and its result is returned. If the predicate is false, None is returned. whenever is to when as flatMap is to map.
Value parameters
p
the boolean predicate that determines whether the block of code should be executed
x
a by-name parameter representing the block of code returning an Option of type X
Attributes
Returns
an Option containing the result of the block of code if p is true, or None if p is false