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}}==
* 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
<syntaxhighlight>
* for wrapping nullable and non-nullable values respectively.
 
* The class instance method, "flatMap", acts as the bind function. *
<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 {
 
908

edits