From: Martin DeMello Date: 2006-08-07T05:58:42+09:00 Subject: Re: Iterating over an array n element at a time On 8/6/06, Rick DeNatale wrote: > On 8/5/06, Martin DeMello wrote: > > require 'enumerator' > > > > module Enumerable > > def eachn(&block) > > n = block.arity > > each_slice(n) {|i| block.call(*i)} > > end > > end > > > > a = (1..10).to_a > > a.eachn {|x,y,z| p [x,y,z]} > > Nice! As it turns out that *i in the block.call invocation isn't > needed. The proc call method does the right thing in this case. Huh - you're right, block.call(i) works nicely without the splat. I guess it's because the argument list 'picks apart' the array. Good catch. martin