method

collect

v1_9_1_378 - Show latest stable - Class: Enumerable
collect()
public

Returns a new array with the results of running block once for every element in enum.

(1..4).collect {|i| i*i }   #=> [1, 4, 9, 16]
(1..4).collect { "cat"  }   #=> ["cat", "cat", "cat", "cat"]

1Note

Video Explnation of the collect method

MattStopa ยท Mar 11, 2012