Created
July 13, 2014 17:09
-
-
Save dacr/b3f4f84f76be09e1a618 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
scala> def from1:Option[String]=None | |
from1: Option[String] | |
scala> def from2:Option[String]=Some("found") | |
from2: Option[String] | |
scala> def from3:Option[String]={println("oups"); Some("found again")} | |
from3: Option[String] | |
scala> val alts=from1#::from2#::from3#::Stream.empty | |
alts: scala.collection.immutable.Stream[Option[String]] = Stream(None, ?) | |
scala> alts.find(_.isDefined).getOrElse(Some("Default value")) | |
res3: Option[String] = Some(found) | |
scala> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment