Created
September 23, 2016 15:20
-
-
Save xnull/4f5a86cff3027dff498cea72b6f6cd5d 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
object Main extends App { | |
val a: Option[Int] = Some(1) | |
val b: Option[Int] = None | |
val c: Option[Int] = Some(2) | |
(a, b, c) match { | |
case (Some(x), None, Some(z)) => | |
println("1") | |
case (Some(x), Some(y), None) => | |
println("2") | |
} | |
val multi: (Option[Int], Option[Int], Option[Int]) = (a, b, c) | |
val multiList: List[Option[Int]] = a :: b :: c :: Nil | |
multiList match { | |
case l if l.forall(_.nonEmpty) => | |
println("wowowo") | |
case Some(x) :: Some(z) :: Some(y) :: Nil => | |
println(s"a: $x, c: $y") | |
case Nil => | |
println("Oh no, everything is wrong") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment