andela-amagana
11/30/2017 - 8:42 AM

Enumerable collect

# .collect performs an operation on each element of the object it’s
# invoked on and returns a new Array


colors = [‘red’, ‘green’, ‘blue’]
colors.collect { |color| “bright_color_#{color}’ }

(1..10).collect { |num| num * num }