What's the Groovy equivalent to Python's dir()? -
in python can see methods , fields object has with:
print dir(my_object) what's equivalent of in groovy (assuming has one)?
looks particulary nice in groovy (untested, taken link code credit should go there):
// introspection, know details classes : // list constructors of class string.constructors.each{println it} // list interfaces implemented class string.interfaces.each{println it} // list methods offered class string.methods.each{println it} // list methods names string.methods.name // fields of object (with values) d = new date() d.properties.each{println it} the general term looking introspection.
Comments
Post a Comment