Skip to content

Instantly share code, notes, and snippets.

@melix
Created October 2, 2012 18:22
Show Gist options
  • Save melix/3822023 to your computer and use it in GitHub Desktop.
Save melix/3822023 to your computer and use it in GitHub Desktop.
Statically compiled builder
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