On Sat, Jan 15, 2011 at 2:59 PM, Tony Arcieri <tony.arcieri / medioh.com> wrote:

> Ruby, interestingly enough, generally views state as immutable data. You
> generally have to explicitly specify you want to mutate state by placing a !
> on the end of a method name (e.g. Array#reverse vs Array#reverse!). Most
> operations are not mutable by default, but instead return new versions of
> the object in question with the given transformation applied.

That's fairly misleading. There are lots of mutating operations in
Ruby that don't have a ! at the end of the method name (and, IIRC,
there are some non-mutating methods that do have a !). The bang
notation generally distinguishes a more-dangerous operation from a
less-dangerous operation that has (aside from the bang) the same name.
It is very common for the danger noted by the distinction to be
between non-mutating and mutating operations that are otherwise
similar, but where no similar non-mutating method exists, mutating
methods generally don't have a bang in their name (e.g., for instance
methods of Hash, clear, delete, delete_if, keep_if, rehash, replace,
store, and update are all mutating methods without the bang in their
method names, while only the three mutating methods with non-mutating
equivalents of otherwise-identical name have bangs: reject!, select!,
and merge!; in fact, update -- with no bang -- is a synonym for
merge!.)