atom feed5 messages in org.codehaus.groovy.userRe: [groovy-user] How can I add map v...
FromSent OnAttachments
RickJul 15, 2009 7:27 pm 
Jochen TheodorouJul 15, 2009 7:45 pm 
RickJul 15, 2009 7:53 pm 
RickJul 15, 2009 8:47 pm 
Jörg StaudemeyerJul 16, 2009 12:44 am 
Subject:Re: [groovy-user] How can I add map values to an already instantiated object?
From:Jochen Theodorou (blac@gmx.org)
Date:Jul 15, 2009 7:45:40 pm
List:org.codehaus.groovy.user

Rick schrieb:

I know I can do:

//#1 class Person { def name def address }

def map = [name: "rick"] Person p = new Person( map ) println "person name = ${p.name <http://p.name>}, address = ${p.address}"

new Person(*:map) should do too

But I have a case where I'm going to be collecting some maps and I'd like to add them as I go along to Person...

//#2 def map = [name: "rick"] person --> //add the map to Person to populate the Person fields def map2 = [address: "boo"] person --> //continue to add map2 to person

how about: new Person(*:map, *:map2)

bye blackdrag