Last active
August 29, 2015 14:24
-
-
Save jonatasemidio/52ee4d8873949448069a to your computer and use it in GitHub Desktop.
Listando classes diferentes com metodos iguais
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
Object.metaClass.findAll{println it.toString()} | |
class Dog{ String name; public String toString(){ return this.name } } | |
class Cat{ String name; public String toString(){ return this.name } } | |
class Cow{ String name; public String toString(){ return this.name } } | |
dog = new Dog(name: 'toto') | |
cat = new Dog(name: 'lili') | |
cow = new Dog(name: 'mumu') | |
[dog, cat, cow].each { it.findAll() } | |
[dog, cat, cow]*.findAll().sum() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment