Like most iterator methods, each_slice
returns an enumerable when called without a block since ruby 1.8.7+, which you can then call further enumerable methods on. So you can do:
arr.each_slice(2).with_index { |(a, b), i| puts "#{i} - #{a}, #{b}" }
Like most iterator methods, each_slice
returns an enumerable when called without a block since ruby 1.8.7+, which you can then call further enumerable methods on. So you can do:
arr.each_slice(2).with_index { |(a, b), i| puts "#{i} - #{a}, #{b}" }