FP

com.phasmidsoftware.visitor.util.FP
object FP

Provides utility functions for functional programming.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
FP.type

Members list

Value members

Concrete methods

def whenever[X](p: Boolean)(x: => Option[X]): Option[X]

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