Things That Newcomers to Ruby Should Know (11/24/02)

It’s all a matter of what you’re used to. My guess is that most developers
that have spent significant time using languages that support ++ and --,
such as C++ and Java, miss having them in Ruby. The extra keystrokes are
one issue, but a bigger one to me is just having to remember that they
aren’t supported in Ruby. It wouldn’t be a problem if I could only program
in Ruby, but since I still have to code in Java a lot (not necessarily by
choice), I end up typing the following in Ruby.

i++ backspace backspace space += space 1

···

-----Original Message-----
From: Rando Christensen [mailto:rando@babblica.net]
Sent: Monday, November 25, 2002 4:11 PM
To: ruby-talk@ruby-lang.org
Cc: dcarrera@math.umd.edu
Subject: Re: Things That Newcomers to Ruby Should Know (11/24/02)

Tue, 26 Nov 2002 06:30:36 +0900: Daniel Carrera (Daniel Carrera
dcarrera@math.umd.edu):

  1. Ruby has no pre/post increment/decrement operator. For
    instance,
    x++ or x-- will fail to parse.

Why is that? x++ and x-- are very convenient. I sort of understand
why++x and --x don’t exist. But why can’t numbers have a “++” and
“–” method?

I don’t see it as that big of a deal. “very convenient”? How
about “marginally convenient”? Really, how much more
convenient is this:

x++

over this?

x += 1

By my count, it’s two spaces, a shift key, and an extra character. And
you can drop the spaces if you’d like. But the second form certainly
seems more clear to me, and I even use +=1 over ++ in /all/
languages I
code in.

If Ruby supported neither ++ /nor/ +=, then it’d get a little
annoying,
as you’d have to x = x + 1, but I really just don’t see what makes it
“very convenient”.


< There is a light that shines on the frontier >
< And maybe someday, We’re gonna be there. >
< Rando Christensen / rando@babblica.net >


WARNING: All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.