Le 27 ao 08:29, timr a rit :

> [1,2,3].collect{|item| item + 10} # => [11,12,13]
> [1,2,3].collect_until({|x| x%2 == 0}) {|item| item + 10} # => [11,12]

Why not something like this :

class Array
  def collect_until
    n = []
    self.each do |e|
      r, brk = yield e 
      n << r
      break if brk
    end
    n
  end
end

Used like this :

>> [1,2,3].collect_until { |x| [ x + 10 , (x % 2 == 0) ] }
=> [11, 12]

Not very pretty, but it does the job.

Fred
-- 
Actual dialogue from the end of the battle:
Cleric:  "Keep hitting it!"
Paladin: "It's dead."
Fighter: "Yeah, but it's not dead enough."  (David P. Murphy in the SDM)