Created
August 10, 2013 21:45
-
-
Save danclien/6202300 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
def wrap(in: Option[String]) : Option[String] = { | |
println("Running") | |
in | |
} | |
//Setup Option[String]s | |
lazy val maybeValue1 : Option[String] = wrap(Some("Value1")) | |
lazy val maybeValue2 : Option[String] = wrap(None) | |
lazy val maybeValue3 : Option[String] = wrap(Some("Value3")) | |
// Checking each value using a for comprehension | |
(for { _ <- maybeValue1; _ <- maybeValue2; _ <- maybeValue3 } yield ()) match { | |
case None => println("Handle error here") | |
case _ => println("Do stuff here") | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment