From: Avi Bryant Date: 2001-01-30T17:42:54+09:00 Subject: [ruby-talk:10117] Re: newbie list questions Sorry, slight correction: > module Enumerable > def each_n(n) > n_items = [] > each do |i| > n_items << i > if n_items.size == n > yield n_items > n_items = [] > end > end yield n_items unless n_items.empty? #*** > end > end > > [1,2,3,4,5,6].each_n(3) do |a,b,c| > puts "#{a}, #{b}, #{c}" > end > > > #=> 1,2,3 > #=> 4,5,6 > > -Avi >