Method: Immutable::Vector#take_while

Defined in:
lib/immutable/vector.rb

#take_whileVector, Enumerator

Gather elements up to, but not including, the first element for which the block returns nil or false, and return them in a new Vector. If no block is given, an Enumerator is returned instead.

Examples:

Immutable::Vector[1, 3, 5, 7, 6, 4, 2].take_while { |e| e < 5 }
# => Immutable::Vector[1, 3]

Returns:



754
755
756
757
# File 'lib/immutable/vector.rb', line 754

def take_while
  return enum_for(:take_while) if not block_given?
  self.class.new(super)
end