From: timr Date: 2010-08-27T16:10:07+09:00 Subject: Re: how about Array#collect_until Here is an awful hacked solution...perhaps someone come up with a prettier solution class Array def try(something) contents = self.dup while contents.length != 0 item = contents.shift result = yield(item) if something.call(result) p result break else p result end end end end %w[ find out if that this but not the other mother mouth].try(Proc.new {|word| word[-2,2] == 'st' }){|item| item + "t" } puts "another attempt" [1,6,7,5,3,0,10,12,14].try(Proc.new {|num| num > 25 }){|item| item * 4 } puts "another attempt" [1,2,3].try(Proc.new {|x| x%2 == 0}) {|item| item + 10} RESULTS: "findt" "outt" "ift" "thatt" "thist" another attempt 4 24 28 another attempt 11 12