The pre/post increment/decrement operator (++
and --
) are pretty standard programing language syntax (for procedural and object oriented languages, at least).
Why doesn't Ruby support them? I understand you could accomplish the same thing with +=
and -=
, but it just seems oddly arbitrary to exclude something like that, especially since it's so concise and conventional.
example:
i = 0 #=> 0
i += 1 #=> 1
i #=> 1
i++ #=> expect 2, but as far as I can tell,
#=> irb ignores the second + and waits for a second number to add to i
I understand FixNum is immutable, but if += can just instanciate a new FixNum and set it, why not do the same for ++?
Edit
Is consistency in assignments containing the =
character the only reason for this, or am I missing something?