Enum Option
The Option type presents a way to hold either a value of A, or None, with None being valid for any Option. A common use for this is as a return type for functions that may fail, but have no meaningful error message.
enum Option[A]
{
None,
Some(A)
}
define and(other: Option[B]): Option[B]
If self is a Some, this returns other.
Otherwise, this returns None.
define and_then(fn: Function(A => Option[B])): Option[B]
If self is a Some, this calls fn with the value within the Some. The result is the result of the Option returned by fn.
Otherwise, this returns None.
define is_none: Boolean
If self is a Some, this returns false.
Otherwise, this returns true.
define is_some: Boolean
If self is a Some, this returns true.
Otherwise, this returns false.
define map(fn: Function(A => B)): Option[B]
If self is a Some, this returns a Some holding the result of fn.
Otherwise, this returns None.
define map_or(alternate: B, fn: Function(A => B)): B
If self is a Some, returns the result of fn.
Otherwise, this returns alternate.
define or(alternate: Option[A]): Option[A]
If self is a Some, this returns self.
Otherwise, this returns alternate.
define or_else(fn: Function( => Option[A])): Option[A]
If self is a Some, this returns self.
Otherwise, this returns the result of calling fn.
define unwrap: A
define unwrap_or(alternate: A): A
If self is a Some, this returns the value with self.
Otherwise, this returns alternate.
define unwrap_or_else(fn: Function( => A)): A
If self is a Some, this returns the value with self.
Otherwise, this returns the result of calling fn.