MaybeImpl<T> extension

Impl for Maybe

on

Properties

has bool
Get the Value if it has
no setter
isNone bool
Returns true if the this is a None value
no setter
isSome bool
Returns true if the this is a Some value
no setter
val → T?
no setter

Methods

and<U>(Maybe<U>? other) Maybe<U>?
Returns None if the this is None, otherwise returns other
andThen<U>(Maybe<U>? f(T val)) Maybe<U>?
Returns None if the this is None, otherwise calls f with the wrapped value and returns the result
defaultVal(T v) Maybe<T>?
Set a default value when it is None(null)
defaultValFn(T fn()) Maybe<T>?
Set a default value when it is None(null)
flatMap<U>(Maybe<U>? f(T val)) Maybe<U>?
Returns None if the this is None, otherwise calls f with the wrapped value and returns the result
map<U>(U f(T val)) Maybe<U>?
Maps an Maybe
none<R>(R none()) Maybe<R>?
When it not has Value Return Some(none(it))
or(Maybe<T>? other) Maybe<T>?
Returns this if this contains a value, otherwise returns other
orElse(Maybe<T>? f()) Maybe<T>?
Returns this if this contains a value, otherwise calls f and returns the result
some<R>(R some(T val)) Maybe<R>?
fMap
then<U>(U f(T val)) Maybe<U>?
Maps an Maybe
when<R>({R some(T val)?, R none()?}) Maybe<R>?
Pattern matching
xor(Maybe<T>? other) Maybe<T>?
Returns Some if exactly one of this, other is Some, otherwise returns None