Created
October 28, 2012 20:27
-
-
Save bfb/3969774 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 Swimmer { | |
def swim() = println("Swimming...") | |
} | |
abstract class Bird { | |
def fly() = println("Flying...") | |
} | |
class Duck extends Bird with Swimmer { | |
def talk() = println("Duck duck") | |
} | |
var duck = new Duck | |
duck.talk // Duck duck | |
duck.fly // Flying... | |
duck.swim // Swimming... | |
class Athlete { | |
def run() = println("Running...") | |
} | |
var phelps = new Athlete with Swimmer | |
phelps.run // Running... | |
phelps.swim // Swimming... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment