1 module Enumerable 2 def take_while 3 inject([]) do |xs, x| 4 yield x or break xs 5 xs << x 6 end 7 end 8 end