Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: Quintus Newsgroups: comp.lang.ruby Subject: Re: Can I append hash to hashes? Date: Fri, 22 Apr 2011 02:53:46 -0500 Organization: Service de news de lacave.net Lines: 42 Message-ID: <4DB13412.4000108@gmx.net> References: <3d3ff00fedc9442b82823de5ba1d77ae@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303458853 60631 65.111.164.187 (22 Apr 2011 07:54:13 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 22 Apr 2011 07:54:13 +0000 (UTC) In-Reply-To: <3d3ff00fedc9442b82823de5ba1d77ae@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382054 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <4DB13412.4000108@gmx.net> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3367 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 22.04.2011 09:22, schrieb Siratinee Sukachai: > I need to do a hash some kind like this: > Member => {email => Email, name => Name, lastname => Lastname} > > But I get a hash in foreach loop so I need to append a hash to hashes. > e.g. > First round: Member => {email => Email} > Second round: Member => {email => Email, name => Name} > Third round: Member => {email => Email, name => Name, lastname => > Lastname} > > Can I do that and how? > In my case I cannot do the array because I need to use this hash to > generate yaml later. > If I do as the array, the formatting what I get in yaml is not what I > need. > Pls help... > Have a look at the Hash#merge and Hash#merge! methods. http://www.ruby-doc.org/core/classes/Hash.html#M000759 http://www.ruby-doc.org/core/classes/Hash.html#M000758 Vale, Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJNsTQQAAoJELh1XLHFkqha4wwH/RbyOJ6I1HZip5oeAORqYfdB NdZ6g9YNUh3Y/jX9h7UOFptvJIO8E7CMCgP7ptfqk80jOr5AxEzaBAPY3HRqjGIj O0uIt8FIu078KmNiBeP2dVHMKCUEPHGWrfGV4pOYkTEDBO7pmkF/KTEuggIdxHGC gSziditMIpdRqSMeDHufscTCx8OrdU05aLNDiuL8nCpf+HS1Ou5Kyww5FBYbhhD5 Il4BKJyRhZTRYtoAXoSyb9nl+2wZ6/yP36ymQ/37GxmIfVpmQys7mjukjy1mVRbf OPFqfOdhwnavrzhKYuZJvGMHxegQztjOvsDDZ8QvvxcCNP1Fg4EMLcjnckkEOiI= =k4QL -----END PGP SIGNATURE-----