Skip to content

Instantly share code, notes, and snippets.

Created April 23, 2014 06:37
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/11204746 to your computer and use it in GitHub Desktop.
Save anonymous/11204746 to your computer and use it in GitHub Desktop.
// 簡單的 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