Skip to content

Instantly share code, notes, and snippets.

@kiritsuku
Created July 11, 2011 22:19
Show Gist options
  • Save kiritsuku/1076930 to your computer and use it in GitHub Desktop.
Save kiritsuku/1076930 to your computer and use it in GitHub Desktop.
Scala HelloWorld by self reference
object HelloWorld extends App {
val msg = new Hello with World
msg.show
}
trait Message {
def get: String
}
trait World extends Message {
def get = "World"
}
class Hello {
this: Message =>
def show() {
println("Hello "+get)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment