Daniel Schierbeck wrote:
> The current implementation of Hash#each[1]:
>
>    # File lib/facets/core/hash/each.rb, line 19
>    def each(&yld)
>      case yld.arity
>      when 0
>      when 1
>        each_value{|v| yield(v)}
>      else
>        each_pair{|k,v| yld.call(k,v)}
>      end
>      self
>    end
>
> To me it looks like we're creating more Proc objects than necessary.
> Would this not suffice?
>
>    def each(&block)
>      if block.arity < 2
>        each_value(&block)
>      else
>        each_pair(&block)
>      end
>    end

Yes that's much better.

On the other hand, I'm glad you bring this up. Are you actively using
this call? As you hopefully noticed from the docs, this variation of
Hash#each comes with a WARNING:

  # WARNING! Use with caution. Methods from other libraries
  # may depend on the old behavior, expecting a two element
  # array to be passed into a single block argument.

I'm "abstractly" of the opinion that this alternate definition makes
more sense, nonetheless it may just be TOO danagerous for practicel use
b/c of the compatability issue. Would others concur? Or is it safe to
use in limited circumstance as I have been assuming?

T.