Skip to content
instance method

Array#map!

() { (Elem item) -> Elem } -> self
() -> ::Enumerator[Elem, self]
map! {|element| ... } → self
map! → new_enumerator

Alias of #collect!

With a block given, calls the block with each element of self and replaces the element with the block’s return value; returns self:

Example
a = [:foo, 'bar', 2]
a.map! { |element| element.class } # => [Symbol, String, Integer]

With no block given, returns a new Enumerator.

Related: collect; see also Methods for Converting.

See also #collect! #map #max #length also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0