ary.take_while { |arr| block } â new_ary
ary.take_while â Enumerator
ary.take_while â Enumerator
Instance Public methods
Passes elements to the block until the block returns nil
or
false
, then stops iterating and returns an array of all prior
elements.
If no block is given, an Enumerator is returned instead.
See also #drop_while
1 2 | a = [ 1 , 2 , 3 , 4 , 5 , 0 ] a.take_while { |i| i < 3 } #=> [1, 2] |
Please login to continue.