-
each
The each
method iterates over the elements of its calling object and takes a block as an argument. During each iteration, the current element is passed as an argument to the block which is in turn bound to the block parameter. The return value from the block is ignored by each
. When all the iterations are complete, the original calling array is returned by each
.
-
map
The map
method iterates over the elements of its calling object and takes a block as an argument. During each iteration, the current element is passed as an argument to the block which is in turn bound to the block parameter. The return value from the block is appended to a new array. When all the iterations are complete, the new array object is returned by map
.
-
select
The select
method iterates over the elements of its calling object and takes a block as an argument. During each iteration, the current element is passed as an argument to the block which is in turn bound to the block parameter. Only the elements of the calling array for which the block returns a truthy value are appended to a new array. When all the iterations are complete, the new array object is returned by select
.