DEV Community

Discussion on: Arrays and hashes in Ruby

Collapse
 
xngwng profile image
Xing Wang

Great article:

if you are covering arrays and "each" method, it might be worth a while to point out the "map" method. Since they are similiar and yet have very important differences:

Array#each executes the given block for each element of the array.

Array#map also executes the given block for each element of the array, but returns a new array whose values are the return values of each iteration of the block.

Use them effectively is very important. :)