take_while

enum.take_while { |arr| block } â array
enum.take_while â an_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.

a = [1, 2, 3, 4, 5, 0]
a.take_while { |i| i < 3 }   #=> [1, 2]
doc_ruby_on_rails
2015-04-05 02:17:40
Comments
Leave a Comment

Please login to continue.