Skip to content

Instantly share code, notes, and snippets.

@al3x
Created September 2, 2008 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save al3x/8456 to your computer and use it in GitHub Desktop.
Save al3x/8456 to your computer and use it in GitHub Desktop.
trait WhoAreYou {
def whatClassAmI: Class[_] = this.getClass
println("I've been mixed into " + whatClassAmI)
if (whatClassAmI == classOf[Bar]) {
println("Holy cow batman, I'm part of a Bar")
}
}
class Foo extends WhoAreYou
class Bar extends WhoAreYou
object MyApp {
val f = new Foo
val b = new Bar
def main(args: Array[String]) {
println("foo " + f.whatClassAmI)
println("bar " + b.whatClassAmI)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment