Option<A> class abstract

Simple Option monad implementation

Implementers

Constructors

Option()

Properties

hashCode int
The hash code for this object.
no setterinherited
isDefined bool
True if Some of A else false
no setter
isEmpty bool
True if None else false
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

contains(A candidate) bool
Return true if this Option is a Some and value inside equal candidate
exists(bool predicate(A a)) bool
Return true if this option is nonempty and the predicate returns true Otherwise return false
filter(bool predicate(A a)) Option<A>
Return current Option if it's nonempty and predicate application return true. Otherwise return None
flatMap<Z>(Option<Z> f(A a)) Option<Z>
Return Application of f on a inside Some if isDefined else None
fold<Z>(Z onNone(), Z onSome(A a)) → Z
Applies onNone if this is a None or onSome if this is a Some of A
getOrElse(A? caseElse()) → A?
Return a inside Some else supplied caseElse if None
map<Z>(Z f(A a)) Option<Z>
Return Some of Application of f on a inside Some if isDefined else None
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse<B>(Option<B> caseElse()) Option
Return inchanged Option if Some else supplied caseElse if None
toEither<L>(L leftValue) Either<L, A>
Consider that None is a Left and Some is a Right(a)
toLeft(A caseNone) Either<A, A>
Return Left from Option
toRight(A caseNone) Either<A, A>
Return Right from Option
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

cond<A>(bool test, A value) Option<A>
If the condition is satify then return value in Some else None
empty<A>() Option<A>
Return None Option
of<A>(A? a) Option<A>
Return None if null else Some of A