Skip to content

Instantly share code, notes, and snippets.

@bfb
Created October 28, 2012 20:27
Show Gist options
  • Save bfb/3969774 to your computer and use it in GitHub Desktop.
Save bfb/3969774 to your computer and use it in GitHub Desktop.
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