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

Enumerable each & map

# .each performs an operation on each element of the object
# NO new array is returned 

doubled_array = (1..4).each { |num| num * 2 }

# .map performs an operation each element of an object and return a new array

uppercase_array = [‘alex’, ‘magana’, ‘gatobu’].map { |name| name.upcase }