On Thursday 28 August 2008 16:25:59 Joel VanderWerf wrote: > John Pritchard-williams wrote: > > I did check my Ruby books by the way, but they just "unlike C there is > > no ++ operator in Ruby...." :) > > In ruby, operators are methods and they operate on objects, not on > variables. That's not really a valid reason, and not entirely true -- there is no += method for you to define. It behaves as though it's a macro: foo += 1 #becomes foo = foo + 1 I see no reason there couldn't be a ++ operator that behaves the same way: foo ++ # becomes foo += 1 # or, probably better: foo = foo.succ You can define foo=, and you can define +, but you can't define +=. Why not add a ++ that works the same way += does? ... Then again, why pollute our namespace with an operator that would see so little use? I can't remember the last time I had to use "+=1" in Ruby.