Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2014 06:44
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 anonymous/11204852 to your computer and use it in GitHub Desktop.
Save anonymous/11204852 to your computer and use it in GitHub Desktop.
trait Car {
def drive() {
println 'Car.drive()'
}
}
trait Bike {
def drive() {
println 'Bike.drive()'
}
}
class DrivingThing implements Car, Bike {
}
class DrivingThing2 implements Bike, Car{
}
// 最後的優先
obj = new DrivingThing()
obj.drive() // Bike.drive()
obj2 = new DrivingThing2()
obj2.drive() // Car.drive()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment