From: botp Date: 2010-08-28T12:58:23+09:00 Subject: Re: how about Array#collect_until On Sat, Aug 28, 2010 at 4:15 AM, Christopher Dicely wrote: > module Enumerable >  def through >    Enumerator.new do |yielder| >      self.each do |val| >        yielder.yield(val) >        break if yield val >      end >    end >  end > end nice. i'd add that to my lib if you don't mind ;-) now i can do eg, [1,2,3].through{|x| x%2==0}.with_index.map{|x,i| [x,i,x+i]} #=> [[1, 0, 1], [2, 1, 3]] i wonder why ruby's take_while defaulted to array when in blocked form... thanks and best regards -botp