Optional<T> extension
Properties
-
isEmpty
→ bool
-
returns true if value is not null.
no setter
Methods
-
filter(bool f(T))
→ T?
-
returns if value is not empty and matches given function f.
-
flatMap<R>(R f(T))
→ R?
-
returns some value if both this and returned value of function f are some.
-
fold<R>(R ifEmpty())
→ R Function(R (T))
-
returns value returned from ifEmpty thunk if value is null. otherwise,
returns value gained from applying function f to this value.
-
foreach(void f(T))
→ void
-
do side-effect operation if this value is not empty
-
getOrElse(T els())
→ T
-
returns value if value is not null, else returns given els value.
-
map<R>(R f(T))
→ R?
-
map value using function f if value is not null.
-
mapOr<R>(R f(T), {required R or})
→ R
-
-
toList()
→ List<T>
-
convert optional value into list of length 0 or 1.