The Enumerable (.map)

What Is It?

The method (.map) is a loop that returns an array with the results of running the block for each element on self. It is also known as (.collect)

How To Use It

The .map method is very similar to the .each method syntactically. Wheras (.each) would return whatever is executed in the block, (.map) collects those into an array. Take a look at the example below.

References

Stack Overflow API Dock