find_all

enum.find_all { |obj| block } â array
enum.find_all â an_enumerator
Instance Public methods

Returns an array containing all elements of enum for which the given block returns a true value.

If no block is given, an Enumerator is returned instead.

(1..10).find_all { |i|  i % 3 == 0 }   #=> [3, 6, 9]

[1,2,3,4,5].select { |num|  num.even?  }   #=> [2, 4]

See also #reject.

doc_ruby_on_rails
2015-04-05 00:10:48
Comments
Leave a Comment

Please login to continue.