Created
May 24, 2012 13:32
-
-
Save paganotoni/2781567 to your computer and use it in GitHub Desktop.
Simple Groovy Mixin example
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
class Other { | |
def first = { | |
return list[0] | |
} | |
def hello(){ | |
return "hello ${ myName() }" | |
} | |
} | |
@Mixin( Other ) | |
class Simple { | |
def list = [1] | |
def myName(){ | |
return "Simple" | |
} | |
} | |
println new Simple().hello() | |
println new Simple().first() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment