Optional<T> extension

on
  • T?

Properties

isEmpty bool

Available on T?, provided by the Optional extension

returns true if value is not null.
no setter

Methods

filter(bool f(T)) → T?

Available on T?, provided by the Optional extension

returns if value is not empty and matches given function f.
flatMap<R>(R f(T)) → R?

Available on T?, provided by the Optional extension

returns some value if both this and returned value of function f are some.
fold<R>(R ifEmpty()) → R Function(R (T))

Available on T?, provided by the Optional extension

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

Available on T?, provided by the Optional extension

do side-effect operation if this value is not empty
getOrElse(T els()) → T

Available on T?, provided by the Optional extension

returns value if value is not null, else returns given els value.
map<R>(R f(T)) → R?

Available on T?, provided by the Optional extension

map value using function f if value is not null.
mapOr<R>(R f(T), {required R or}) → R

Available on T?, provided by the Optional extension

toList() List<T>

Available on T?, provided by the Optional extension

convert optional value into list of length 0 or 1.