phrogz / gmail.com wrote:
> Is this whole facet just to avoid typing two extra characters in the
> case where you don't care about the keys? Using standard Ruby 1.8.4
> without facets:
>
> foo = { :name=>"Gavin", :age=>33 }
> foo.each{ |_,v| p v }
> #=> "Gavin"
> #=> 33

Actually an interesting question. This is one of the earliest facets in
the library. It came out of a discussion with David Black, Matz and
others about Polymorphic behavior between Array and Hash. If we
considered a Hash's key analogous to an Array's index than one case see
how this definition of #each supports that "meshing", eg.

  x = [ :a, :b ]
  x.each { |v| p v }
  x = { 1 => :a, 2 => :b }
  x.each { |v| p v }

See how both array and the hash produce the same result wihtout haveing
to alter the #each statments. You can't currently do that. So this
hash#each method was created more as an "idealistic" expirement of this
concept, then for practical applicaiton --which explain why it
overrides #each vs. using each_value.

I still think it has merit, but as an extension it does have the
potential of breaking other code. So I probably should get rid of it
--and I've known it. But I've sort of left it there as a reminder of
this interesting topic --and indeed it worked! ;-)

T.