Method: Array#take_until

Defined in:
lib/ruby/jruby_hack.rb

#take_until(accumulator = [], &block) ⇒ Array

Takes the longest prefix of elements that do not satisfy the predicate.

Returns:



145
146
147
148
149
150
151
152
# File 'lib/ruby/jruby_hack.rb', line 145

def take_until(accumulator = [], &block)
  # This is in tail call form
  unless empty? or yield(head)
    tail.take_until(head.snoc(accumulator), &block)
  else
    accumulator
  end
end