Created
October 9, 2018 21:16
-
-
Save stasimus/3953d2504c2c00de916a4cd7ff02f1a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* From Scala | |
trait M[A] { def flatMap[B](f: A => M[B]): M[B] } | |
def unit[A](x: A): M[A] | |
*/ | |
fun <A> A.unit(): A? = this | |
fun <A, B> A?.flatMap(func: (A) -> B?): B? = | |
if (this != null) func(this) else null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment