Created
January 23, 2016 00:48
-
-
Save ryanpbrewster/29bfaf3b8b97821504b8 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
class Foo { | |
sealed trait A | |
case class A1(x: Int) extends A | |
case class A2(y: String) extends A | |
case class A3(z: Double) extends A | |
sealed trait B | |
case class B1(z: Int) extends B | |
case class B2(z1: Int) extends B | |
case class Carrier(a: A, b: B) | |
def foo(c: Carrier): Unit = c match { | |
case Carrier(A1(x), B1(y)) => println(x + y) | |
} | |
def bar(a: A, b: B): Unit = (a, b) match { | |
case (A1(x), _) => println(x) | |
case (A2(y), _) => println(y) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment