Created
April 23, 2014 06:37
-
-
Save anonymous/11204746 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 | |
trait SwimmingAbility { | |
def swim() { | |
println "swimming.." | |
} | |
} | |
class Goldfish | |
implements SwimmingAbility // 使用單個 trait | |
{ | |
} | |
def goldfish = new Goldfish() | |
goldfish.swim() // 直接可用 trait 的 method | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment