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
- Uses destination reuse to avoid creating a new array for every mapping in a sequence of transformations.
- How deep it goes
- Demonstrates argument order, destination reuse, and input aliasing without detailing implementation internals.
- Examples
- Builds a sine table by converting degrees to radians and then mapping sine over the same result array.
- What you can do after
- Apply map! in Julia to write transformed values into a preallocated array or reuse a suitable input array.
What to know first
- functional programmingFunctional programming is a programming paradigm that expresses computation through the evaluation and composition of functions, typically favoring immutable data and minimizing mutable state and side effects.
Related concepts
- higher-order functionkind of · A higher-order function is a function that accepts functions as arguments, returns functions as results, or both.
- 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.
- each_entrycontrasts with · each_entry is a Ruby enumeration method that yields each element of a collection to a block.
- enumeratorproduces · An enumerator is a Ruby object that represents and controls iteration over an enumerable source, optionally allowing iteration without supplying a block immediately.
Questions about map!
What is map!?
map! is a mutating collection operation that applies a transformation to elements and writes the resulting values into a destination collection.
Which Manning books explain map!?
The Well-Grounded Rubyist, Fourth Edition and Julia as a Second Language.
What should I know before learning map!?
Manning books that teach map! usually introduce functional programming first.
What is the difference between map! and each_entry?
map! is a mutating collection operation that applies a transformation to elements and writes the resulting values into a destination collection. each_entry is a Ruby enumeration method that yields each element of a collection to a block.
What is map! a kind of?
Map! is a kind of higher-order function. A higher-order function is a function that accepts functions as arguments, returns functions as results, or both.
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.

