collect

ary.collect { |item| block } â new_ary
ary.collect â Enumerator
Instance Public methods

Invokes the given block once for each element of self.

Creates a new array containing the values returned by the block.

See also Enumerable#collect.

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

a = [ "a", "b", "c", "d" ]
a.map { |x| x + "!" }   #=> ["a!", "b!", "c!", "d!"]
a                       #=> ["a", "b", "c", "d"]
doc_ruby_on_rails
2015-03-30 15:41:11
Comments
Leave a Comment

Please login to continue.