Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- }
- }
Add Comment
Please, Sign In to add comment