Created
September 2, 2008 20:23
-
-
Save al3x/8456 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
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