Last active
August 29, 2015 14:21
-
-
Save zjhmale/22989a9f2a0bc1bd0fe2 to your computer and use it in GitHub Desktop.
scala option map filter
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
val a : Option[String] = Some("333") | |
//a: Option[String] = Some(333) | |
a.filter(_.length > 1).map(_.length) | |
//Option[Int] = Some(3) | |
a.filter(_.length > 6).map(_.length) | |
//Option[Int] = None | |
//filter and map function is just for Option type it's just a monad | |
//def filter(p: A => Boolean): Option[A] | |
//def map[B](f: A => B): Option[B] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment