Ternary operator.
Ternary operator. Note that the arguments s and n are call-by-name.
Example
option ? "defined" | "undefined"
Returns the item contained in the Option if it is defined, otherwise, raises an error with the provided message.
Executes the provided side effect if the Option if it is undefined.
Returns the provided function s
applied to item contained in the Option if it is defined,
otherwise, the provided value n
.
Returns the provided function s
applied to item contained in the Option if it is defined,
otherwise, the provided value n
.
This is a syntactic alternative to scalaz.syntax.std.OptionOps#cata
Example:
o.some(_ * 2).none(0)
Returns the item contained in the Option if it is defined, otherwise, the zero element for the type A
Returns the item contained in the Option if it is defined, otherwise, the zero element for the type A
For example:
val o: Option[List[String]] = None val a: List[String] = ~o // List()
Returns the item contained in the Option if it is defined, otherwise, the provided argument.