Groovy: Map vs Expando for dynamic data structures

with Expando…

def builder = new Expando(email: 'my email')
builder.make = { println email }
builder.make()

Result:
my email

with Map…

def builder = [email: 'my email']
builder.make = { println email }
builder.make()

Result:
groovy.lang.MissingPropertyException: No such property: email

Advertisements