Skip to content

Instantly share code, notes, and snippets.

@quii
Created April 12, 2014 08:34
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 quii/10524822 to your computer and use it in GitHub Desktop.
Save quii/10524822 to your computer and use it in GitHub Desktop.
type Quackable = {
def quack(): Unit
}
def listenToSomeQuacking(x: Quackable){
println("Gosh I love the sound of quacks")
x.quack()
}
class Duck{
def quack(){
println("Quack!")
}
}
class Dog{
def bark(){
println("Woof!")
}
}
listenToSomeQuacking(new Duck)
listenToSomeQuacking(new Dog) // compile error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment