From: "David A. Black" Date: 2004-09-20T01:34:50+09:00 Subject: Re: Array#index block and rdetect Hi -- On Sun, 19 Sep 2004, trans. (T. Onoma) wrote: > Couldn't the index of a hash be considered the key? So the block of #index > when applied is the value. i.e. That's how I tend to see it, though Ruby has two interpretations of "index" for hashes: irb(main):007:0> h = Hash[*%w{a b c d}] => {"a"=>"b", "c"=>"d"} irb(main):008:0> h.index("d") => "c" irb(main):009:0> h.each_with_index {|e,i| p i if e[0] == "c"} 1 This is one of the reasons I've always felt that Hash#each_with_index should be eliminated. The "index" in h.each_with_index is not the same as the "index" of h.index. h.each_with_index is effectively equivalent to h.to_a.each_with_index, but with the to_a being hidden. David -- David A. Black dblack@wobblini.net