views:

43

answers:

2

Is it possibly to dynamically set the class of an expando??

Having set

jr = new Expando()

Is there a way to

def end = 'name'

so that

jr.end

will actually give me the value stored in

jr.name

A: 

I'm not sure I understand your question, maybe this will help

jr = new Expando()
jr.end = 'name'
jr.name = jr.end

assert jr.end == jr.name
assert jr.end == 'name'
Don
Maybe I haven't asked it in a logical wayBy changing the def end I want to be able to create lots of different classesi.ejr.namejr.housejr.fieldso that I can assign value to each of these but only if they get created.
john renfrew
A: 

fixed it, need to assign a value at the same time. Doh!

def value = 'some value'
jr."$end" = value
john renfrew