addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [ruby-99] Nested Hashes/Hash of Hashes in Ruby

From: user 1.
Sent on: Tuesday, March 9, 2010 7:02 PM

Thanks Alson. I have created the public gist. You can please access that:?
Appreciate your help.

On Tue, Mar 9, 2010 at 6:55 PM, Alson Kemp <[address removed]> wrote:
? You might paste that somewhere and then post the paste so that the formatting is preserved.

? - Alson

On Tue, Mar 9, 2010 at 6:53 PM, Swarna <[address removed]> wrote:

I have got a question regarding the Hash table in ruby on rails.
I am trying to create a 3-D hashes (hash of hashes) and loop each line of mybuffer to parse the data and dump into the hash of hashes.

For say, here is my sample data:

groupid fnam lname bday?
1 abc xyz jan1
def lmn feb1
2 amy morgan may1
nick cary may6

Here is a sample code..?

myhash = {
my_buffer,each |line|
# use the parser to get the groupid, fname, lname bday
myhash = {groupid=>{fnam=>{"lname"=>lname, "bday"=>bday}}}

Now the problem I am seeing is when i print "myhash" at the end of the function, it just prints only the last line of "mybuffer".?

How can I store all the parsed information in a 3-D Hash table?

Any input is highly appreciated.
Thanks in advance,

Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Swarna ([address removed]) from Silicon Valley Ruby Meetup.
To learn more about Swarna, visit his/her member profile
To unsubscribe or to update your mailing list settings, click here

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

Alson Kemp
[ m: [masked] ]
[ e: [address removed] ]
[ Skype: alsonkemp ]
[ gTalk, Jabber: [address removed] ]

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy