Last active
December 16, 2015 20:09
-
-
Save ishults/a9915bd20b3fd2988100 to your computer and use it in GitHub Desktop.
Multiple assignment using .with()
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
Dog dog = new Dog() | |
//... | |
dog.with { | |
(name, age, color) = ['Rex', 2, Color.BLACK] | |
} | |
assert 'Rex' == dog.name | |
assert 2 == dog.age | |
assert Color.BLACK == dog.color |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment