Each or map?


#1

numbers_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

strings_array = numbers_array.each(&:to_s)

why this code doesnt work..m giving each instead of map..don't they perform same function..ie take every element of array and perform specified operation.


#2

I don't know but map works.


#3

each doesn't take a method as argument, it takes a block. Use map or collect to apply a method to elements of an array.