From: matz@... (Yukihiro Matsumoto) Date: 2001-08-24T11:01:26+09:00 Subject: [ruby-talk:20231] Re: ++ Operator Hi, In message "[ruby-talk:20207] Re: ++ Operator" on 01/08/24, Lars Christensen writes: |> "++" in C/C++ is fundamentally an assignment, or in other words, an |> operation on variable not object, so that it would not fit well in |> object-oriented model. Try "i+=1" instead. | |I don't think of ++ as an assignment, as much as a "modification" to what |it is used one. Having written much C and C++ code, the +, += and |"missing" ++ operators semantics in Ruby are hard for me to accept. | |This is how I would have done it: | |--- | |+= should be a method, not an operator. It modifies the object using |addition or appending. Lot of methods in ruby already modify their object. | | a = b = 2 | a += 2 | a # => 4 | b # => 4 Ah, so you want integers to be mutable? And it may result p 2 # => 4?? Is this what you want? I don't agree. (a) making numbers mutable is plain confusing. (b) in addition, it prohibits immediate numbers (as in Smalltalk, or current Ruby), number preallocation (as in Python), etc. as a result, it may be performance penalty. matz.