Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Adam Adam Newsgroups: comp.lang.ruby Subject: Help on hashing multiple keys and values Date: Wed, 13 Apr 2011 18:33:45 -0500 Organization: Service de news de lacave.net Lines: 25 Message-ID: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1302737648 45728 65.111.164.187 (13 Apr 2011 23:34:08 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Wed, 13 Apr 2011 23:34:08 +0000 (UTC) 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: 381474 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:2796 I'm trying to create a hash with multiple values per key from a tab delimited file. numbers_and_colors.txt example: 1 Red 2 Blue 3 Red 2 Green What I need is a hash that has key 2 assigned to values Blue and Green. Running what I have below just erases the previous key, so puts name_hash["2"] would only show Green. Ruby example: name_hash = Hash.new File.open("numbers_and_colors.txt").each do |file_line| file_line.chomp! line_parts = file_line.split(/\t/) name_hash["#{line_parts[0]}"] = "#{line_parts[1]}" I need this in a hash, so is there another way to go about this? Thanks in advance to any help, as you can probable tell I only started learning Ruby recently. -- Posted via http://www.ruby-forum.com/.