From: Tee Dubb Date: 2010-05-05T20:40:16+09:00 Subject: troubles with nested hashes i'm new to ruby and not that great a programmer so bear with me. i'm trying to dynamically populate a nested hash. below is the structure of what i'm trying to populate devices = { 'macaddr' => { 'packets' => '', 'ip' => '', 'name' => } } macaddr is my unique identifier and it will have certain properties (packets, ip, and name). just so you know i'm reading the information over the network, which is simply a comma separated line of text, and putting that into an array like below. Csv.parse(whatever) do |line| devices['macaddr'] = line[0] devices['macaddr']['packets'] = line[1] end it fails here => devices['macaddr']['packets'] = line[1] i also tried another approach, instead of defining the nested hash i used the code below. devices = Hash.new{|h,k| h[k]=Hash.new(&h.default.proc)} Csv.parse(whatever) do |line| devices['macaddr'] = line[0] devices['macaddr']['packets'] = line[1] end it still fails on the same line, any clue on what i'm doing wrong? also is this the best approach? thanks. -- Posted via http://www.ruby-forum.com/.