Map

suggest change

Returns the changed object, but the original object remains as it was. For example:

arr = [1, 2, 3]
arr.map { |i| i + 1 } # => [2, 3, 4]
arr # => [1, 2, 3]

map! changes the original object:

arr = [1, 2, 3]
arr.map! { |i| i + 1 } # => [2, 3, 4]
arr # => [2, 3, 4]

Note: you can also use collect to do the same thing.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents