Novah Documentation

novah.option

Functions to work with optional values.

Types

Declarations


map

visibility: public
type: (a -> b) -> Option a -> Option b

Maps the function over this option if it has a value. Runtime: O(1)


flatMap

visibility: public
type: (a -> Option b) -> Option a -> Option b

Maps the function over this option if it has a value, but don't wrap the result in another option. Runtime: O(1)


maybe

visibility: public
type: b -> (a -> b) -> Option a -> b

Takes a default value, a function and an option and returns the result of the function applied to this option's value or the default value if the option is empty.


isSome

visibility: public
type: Option a -> Boolean

Returns true if this option contains a value.


isNone

visibility: public
type: Option a -> Boolean

Returns true if this option doesn't contain a value.


unwrap

visibility: public
type: Option a -> a

Extracts the value out of this option. Unsafe: Will thrown an exception if the option is empty. An alias for unwrapOptions and the !! syntactic sugar.


toOption

visibility: public
type: Nullable a -> Option a

Transforms this nullable value into an option. null is represented as None.


toNullable

visibility: public
type: Option a -> Nullable a

Transforms this option into an nullable value. This function should only be used to interact with Java methods.


caseNull

visibility: public
type: b -> (a -> b) -> Nullable a -> b

Receives a default value, a function f and a possible null value. If the value is null returns the default value, otherwise returns f applied to the value.


fromOptional

visibility: public
type: Optional a -> Option a

Transforms a java.util.Optional into an option.


toOptional

visibility: public
type: Option a -> Optional a

Transforms an option into a java.util.Optional.