liveBook · Manning

Map!

map! is a mutating collection operation that applies a transformation to elements and writes the resulting values into a destination collection.

How 2 Manning books explain it

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.

Read how Julia as a Second Language explains map! →

Related concepts

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.