Created
April 12, 2014 08:34
-
-
Save quii/10524822 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
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