Skip to content

Instantly share code, notes, and snippets.

/TestTraitEx5.groovy
Created Apr 23, 2014

Embed
What would you like to do?
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
You can’t perform that action at this time.