On Sun, Jul 20, 2003 at 03:33:43AM +0900, Ben Giddings wrote: > It was a weak attempt to come up with a situation where x += 1 was > useful. Any other times when it is handy? The only time I can think of is when counting things for a summary report: e.g. number of 'good' or 'bad' items seen, number of things changed etc. > I'm on the fence about x++. I use it all the time in other languages, > and it would save some keystrokes when I wanted to do the equivalent > thing in Ruby. I agree it could cause problems if someone tried to do > 0xDEAD++, but 1) it should be easy to write a parser to catch that and > 2) someone who does that is really odd and deserves whatever they get. > On the other hand, right now if you are modifying an object, the method > either has an equal sign in it, or has a bang in it. This would be yet > another special case. Maybe instead Fixnum should have a #succ! method? But then you would be asking for the number itself to be changed, not the variable which contains the reference. As far as I know, x.<anymethod> always leaves variable 'x' pointing at the same object. Mutators mutate objects, not variables. However, x += 1 always leaves 'x' pointing at a *different* object. x = 1 x.succ! would be the same as x = 1 1.succ! which is meaningless. Regards, Brian.