
Kevin R. answered 03/18/22
Software Engineer at tech company that uses Ruby/Rails as main tool.
The map method in Ruby is a method that can be used with an array, hash, or range (an enumerable) to transform or change the data. Below are two examples of the syntax:
Map is sometimes confused with the "each" method which is very similar to "map" however each returns the original unmodified version of the array. With the map function, you can change data and will have the modified array returned.
Another note to be aware of is that sometimes you might see a method called "collect" which is just an alias for map. Collect and map are the same exact method.