Analogous to Option.collect
except that when the function returns null
,
empty Opt
is returned as a result.
Analogous to Option.collect
except that when the function returns null
,
empty Opt
is returned as a result.
Apply side effect only if Opt is empty.
Apply side effect only if Opt is empty. It's a bit like foreach for Opt.Empty
- code to be executed if opt is empty
the same opt
captionOpt.forEmpty(logger.warn("caption is empty")).foreach(setCaption)
Analogous to Option.map
except that when mapping function returns null
,
empty Opt
is returned as a result.
Analogous to Option.map
except that when mapping function returns null
,
empty Opt
is returned as a result.
Like
Option
but implemented as value class (avoids boxing) and treatsnull
as no value. Therefore, there is no equivalent forSome(null)
.If you need a value-class version of
Option
which differentiates between no value andnull
value, use NOpt.