Created
April 23, 2014 06:44
-
-
Save anonymous/11204852 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 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