I am confused with the working of a.map and a.map! on the array
collection.
The documentation is quite clear:
$ ri Array#map
...
...
Invokes the given block once for each element of self.
Creates a new array containing the values returned by the block.
...
...
$ ri Array#map!
...
...
Invokes the given block once for each element of self, replacing the element
with the value returned by the block.
...
...
Methods ending with ! usually modify the original object.
Carlo
···
Subject: what is the difference between a.map and a.map?
Date: Sat 12 Jan 13 04:54:43PM +0900
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)
You'll find this symbol on quite a few methods in Ruby, in general there
will only be a method with "!" (modify the object in place) if there's
also one which returns a new object without changing the original. Look
up "Ruby Bang Methods" for more info.