From: MikkelFJ Date: 2001-08-24T07:50:07+09:00 Subject: [ruby-talk:20217] Re: ++ Operator "Paul Brannan" wrote in message news:Pine.LNX.4.33.0108231544160.9005-100000@zaphod.atdesk.com... > > The only moment where I miss the "++" is actually when I need to increment > > a Number... Writing "a += 1" is just.. depressing.. ;p. > > Not to mention that a += 1 is less efficient (in terms of speed) than a = > a.succ(), and the latter really doesn't imply that we are incrementing a > (not to mention that it's more ugly). Speed is a bad argument for language design. Any decent Ruby compiler / interpreter would optimize += 1 if possible. If it doesn't, it should be fixed there, and not in the language itself. That said, I would also like a ++ operator, but I agree with Matz argument about inconsistency with non-numeric types, given the += 1 definition. An object should either have a "one" element as understood from algebra which is the generalized += 1 approach, or a succ method. The latter is more intuitive and practical, although it generally also requires a pred method for symmetri with --. But I see no problem in having ++ being an alias for a succ. method. All objects are not required to support pred/succ., but obviously 1.succ() -> 2 by default and "a".succ() -> "b". Mikkel