Map!
map! is a mutating collection operation that applies a transformation to elements and writes the resulting values into a destination collection.
The Well-Grounded Rubyist, Fourth Edition
map! is a mutating collection method that replaces each element with the value produced by applying a transformation block.
- How it is used
- Transforms existing array or set elements in place rather than collecting a new array with map.
- How deep it goes
- Defines in-place mapping and contrasts its receiver types with map, without detailing map!’s implementation or return value.
- Examples
- Shows an array of names changed in place with `names.map!(&:upcase)`.
- What you can do after
- Apply it via Ruby’s Array#map! or Set#map! when the collection itself should change.
Read how The Well-Grounded Rubyist, Fourth Edition explains map! →
Julia as a Second Language
map! is a Julia mutating mapping function that writes transformed elements into a destination array.
- How it is used
- Reuses a preallocated array while transforming a collection, avoiding a new array for each mapping.
- How deep it goes
- Explains argument order and demonstrates two successive mappings, but does not develop a broader procedure for managing mutation.
- Examples
- Uses a sine table that converts degree values to radians, then replaces them with sine values in one array.
- What you can do after
- Apply it via Julia’s map! to write transformations into a destination array and, when suitable, reuse that array as input.
Related concepts
- higher-order functionkind of · A higher-order function is a function that accepts functions as arguments, returns functions as results, or both.
- each_entrycontrasts with · each_entry is a Ruby enumeration method that yields each element of a collection to a block.
- blockuses · A code block is a grouped region of code treated as a unit, with boundaries and scope or execution behavior determined by its language or context.
- enumeratorproduces · An enumerator is a Ruby object that represents and controls iteration over an enumerable source, optionally allowing iteration without supplying a block immediately.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

