I there a way to do nested evaluation of "$-Strings" in Groovy like, e.g.
def obj = {["name":"Whatever", "street":"ABC-Street", "zip":"22222"]}
def fieldNames = ["name", "street", "zip"]
fieldNames.each{ fieldname ->
def result = " ${{->"obj.${fieldname}"}}" //can't figure out how this should look like
println("Gimme the value "+result);
}
Result should be:
Gimme the value Whatever
Gimme the value ABC-Street
Gimme the value 22222
My attempts to solve this either don't give proper results (e.g. just obj.street} or won't compile at all. I simply haven't understood the whole concept so far it seems. However, seeing this: http://groovy.codehaus.org/Strings+and+GString I believe it should be possible.