From: "Luke A. Kanies" Date: 2004-01-11T00:25:49+09:00 Subject: Question on hashes and init block Hi all, I'm using the trick someone mentioned here a few weeks ago to attach a block to a hash so I can return an error if someone tries to access a key which does not exist: a = Hash.new { |key,value| raise "Missing key [#{key}] => [#{value}]" } puts a["yay"] Strangely, this results in the following: missing [] => [yay] nil In other words, I try to access a key, and the attached block complains that that key doesn't exist, but it treats it as a value instead. I can work around this, obviously, because it's consistent, but can someone explain this to me? Is this behaviour going to change? Am I just not understanding what is going on? Thanks, Luke -- "What's the good of having mastery over cosmic balance and knowing the secrets of fate if you can't blow something up?" -- Terry Pratchett, "Reaper Man"