How to get Class type
Posted
by Tomáš
on Stack Overflow
See other posts from Stack Overflow
or by Tomáš
Published on 2010-06-03T10:34:04Z
Indexed on
2010/06/03
10:54 UTC
Read the original article
Hit count: 312
groovy
Hi gurus
How to determine Class type of Object in collection?
class Human{...}
class Man extends Human{...}
class Women extends Human{...}
def humans = Human.findAll()
humans.each(){ human ->
// ??? , it is not work
if ( human instanceof Man ) { println "Man" }
if ( human instanceof Woman ) { println "Woman" }
}
Thanks a lot,
Tom
© Stack Overflow or respective owner