Created
October 2, 2012 18:22
-
-
Save melix/3822023 to your computer and use it in GitHub Desktop.
Statically compiled builder
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 Xml { | |
boolean called = false | |
void bar() { called = true } | |
void foo(@DelegatesTo(Xml)Closure cl) { cl.delegate=this;cl() } | |
} | |
def mylist = [1] | |
def xml = new Xml() | |
xml.foo { | |
mylist.each { bar() } | |
} | |
assert xml.called |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment