From: Chad Thatcher Date: 2006-12-09T10:39:15+09:00 Subject: Re: Beginners question about Array#assoc Actually, I am still having trouble. My code is: res = dbh.query("SELECT tag ...blah blah") masters = Array.new res.each_hash do |row| p row["tag"] if masters.assoc(row["tag"]) newMaster = { "subtags" => Array.new, "master" => 'a' } masters.push [row["tag"], newMaster] end ..... And here is my output: "852" ./prep_tags_yaml_02.rb:65: undefined method `[]' for nil:NilClass (NoMethodError) from ./prep_tags_yaml_02.rb:8 I tried populating the "masters" array with an init line like: masters = [["asdf", "agf"], ["bb", "behe"]] and it works, but this doesn't help as the array has top be empty to begin with. Puzzling... -- Posted via http://www.ruby-forum.com/.