Monads/Maybe monad: Difference between revisions
m
Added language identifier and moved a comment.
m (Added language identifier and moved a comment.) |
|||
Line 992:
=={{header|Java}}==
<syntaxhighlight>▼
▲<syntaxhighlight lang="java">
import java.util.Optional;
▲ * Java has a built-in generic "Maybe" monad in form of the Optional<T> class.
▲ * The class has static methods, "of" and "ofNullable", which act as the unit function
▲ * for wrapping nullable and non-nullable values respectively.
▲ * The class instance method, "flatMap", acts as the bind function. *
public final class MonadMaybe {
|