[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: RFC - Recursive Array Method call acting on element batches

Yukihiro Matsumoto

11/24/2007 5:47:00 PM

Hi,

In message "Re: RFC - Recursive Array Method call acting on element batches"
on Sun, 25 Nov 2007 02:35:02 +0900, rubydeckard@gmail.com writes:

|I work for the Department of Redundancy Department and I'm thinking
|there must be a better, more elegant way to doing the following:
|
|With an array of 200 elements
|Call a method to act on 10 elements at a time
|Repeat until all elements are processed.
|Return the processed array.

Hmm, how about

ary = ... # array of 200 elements
ary.each_slice(10).map{|x| ...}

in 1.9?

matz.