Skip to content

Instantly share code, notes, and snippets.

@tstone
Created April 14, 2014 17:52
Show Gist options
  • Save tstone/10669227 to your computer and use it in GitHub Desktop.
Save tstone/10669227 to your computer and use it in GitHub Desktop.
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