Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.42 KB | None | 0 0
  1. import scalaz.std.option._
  2. import scalaz.syntax.std.option._
  3.  
  4. // the standard scala way:
  5. for {
  6.   a <- Some(12)
  7.   b <- None: Option[Int]
  8. } yield a + b
  9. // None is of type Option[Nothing] by default,
  10. // so in order to force it to type-check I have to write None: Option[Int]
  11.  
  12. // the scalaz way:
  13. for {
  14.   a <- 12.some
  15.   b <- none[Int]
  16. } yield a + b
  17. // same goes for none in scalaz,
  18. // but it has none[Int] for convenience
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement