map
Transforms each element and produces a new arr.
Syntax
arr.map { |e| newValue }Description
Applies the block operation to each element; returns a new arr. Same as collect.
Example
Loading editor…
Expected output
[2, 4, 6]
When to use?
Transforming the list.