Created
April 14, 2014 17:52
-
-
Save tstone/10669227 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 A | |
class B extends A | |
class C extends B | |
val a = new A | |
val b = new B | |
val c = new C | |
def f[T : ClassTag](a: A) = a match { | |
case _: T => "is given type" | |
case _ => "NOT given type" | |
} | |
f[B](c) | |
// => "is given type" | |
f[C](c) | |
// => "is given type" | |
f[C](a) | |
// => "NOT given type" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment