Say I have the following code in groovy:
class Human {
Face face
}
class Face {
int eyes = 2
}
def human = new Human(face:new Face())
I want to access the eyes
property using the []
:
def humanProperty = 'face.eyes'
def value = human[humanProperty]
But this does not work as I expected (as this tries to access a property named 'face.eyes' on the Human object, not the eyes property on the human.face property).
Is there another way to do this?