From: GOTO Kentaro Date: 2001-11-26T00:28:06+09:00 Subject: [ruby-talk:26452] Re: ++operator and sorted hashes In message "[ruby-talk:26450] Re: ++operator and sorted hashes" on Sun, 25 Nov 2001 23:44:30 +0900, Jakub Travnik writes: > > Is there a certain reason why the ++operator is not implemented ? > > In c/c++: a=5; a++; > > In ruby: a=5; a+=1 > In Ruby everthing is object, > a++ means add one in C. > What this should mean for String? for Regexp? for Your own class? > It does not have usefull object semantic. I'd like to add another explanation. In Ruby, all operators are bound to method, which is operations to an object. So, if ++ is introduced, (a = 5; a++) means (5++). On the other hand, C's ++ is operation to an variable but not to data essentially. This is not suitable for a numerical object. -- Gotoken