Created
September 3, 2011 13:57
-
-
Save fumokmm/1191220 to your computer and use it in GitHub Desktop.
Using closure for temporary block.
This file contains hidden or 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
@groovy.transform.Canonical | |
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