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
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.

Read how Julia as a Second Language explains map! →

What to know first

Related concepts

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.