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
Optionbut implemented as value class (avoids boxing) and treatsnullas no value. Therefore, there is no equivalent forSome(null).If you need a value-class version of
Optionwhich differentiates between no value andnullvalue, use NOpt.