"Paul Battley" <pbattley / gmail.com> writes:

> I'd also add
> * If appropriate, inspect the arity of the block and provide the
> requested number of parameters.
>
> Hash#each's behaviour is a good example:
> hash = {:a=>1, :b=>2}
> hash.each { |x| p x }
> # [:b, 2]
> # [:a, 1]
> hash.each { |k,v| puts "#{k.inspect} => #{v.inspect}" }
> # :b => 2
> # :a => 1

You don't need to -- just yield the array.

irb(main):001:0> class C
irb(main):002:1>   def each
irb(main):003:2>     yield [1,2]
irb(main):004:2>     yield [3,4]
irb(main):005:2>   end
irb(main):006:1> end
=> nil
irb(main):007:0> C.new.each{|a| p a}
[1, 2]
[3, 4]
=> nil
irb(main):008:0> C.new.each{|a,b| p [a,b]}
[1, 2]
[3, 4]
=> nil