Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using closure for temporary block.
class Person{ def name }
List<Person> list = {def list = []; ['taro', 'jiro', 'sabuchan'].each{list << new Person(it)}; list }()
List<Person> list2 = ['taro', 'jiro', 'sabuchan'].collect{ new Person(it) }
assert list == list2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.