.. and as Integers are immutable ++ cannot change the underlying object.
One could define ++ if one wanted, but it can only work on mutable objects
I think the OP deserves the fuller explanation; Why are integers
immutable? Consider this:
a = 2
b = a
a++
Since everything is an object, 'a' references the object '2' and b
should reference it too after the assignment. Then 'a++' should
increment the object referenced by both a and b? This would of course
be possible, but it would be a rather huge performance penalty to keep
something as simple as integers as references to objects everywhere.
Ruby keeps 'small-enough' integers in the object reference (pointer)
to improve performance. Hence 'b = a' results in an actual copy being
taken of the value '2'. If you increment 'b', 'a' would retain its old
value, breaking the concept that a variable is always just a
reference. Ruby opts for immutable Integers instead.
Lars