From: Austin Ziegler Date: 2002-12-02T08:52:44+09:00 Subject: Re: Ruby ++, the one element and generators On Mon, 2 Dec 2002 05:01:35 +0900, Mauricio Fern�ndez wrote: > WARNING: rather long. [I haven't really had time to read this in depth. I scanned it.] This seems like an overly complex solution to a facility that I personally haven't seen a really demonstrated need for. IMO, ++ adds no real value. It could be "nice", but that nice-ness comes at changing the way that variables work in Ruby -- which is *just* as references to objects. In the three Ruby projects that I've done, I have only one where I've done "a += 1" (although it's all over that one, and I could probably refactor that code to be much cleaner), and that a += 1 behaviour is for a rather inconsequential purpose (status update). It would be nicer to be able to do Inc(a) or a++, but the cost -- to the Ruby language, IMO -- of doing such a thing isn't worth the minor savings of keyboarding. To me, ++ has a HUGE downside: it's an assignment masquerading as an increment. There is nothing for the novice which suggests that a++ is actually assigning as well as incrementing, unlike a += 1. In C-derived languages, I'll use a++; in Pascal, I'll use Inc(a). In Ruby, however, I'll tend to use a.each, a.each_with_index, a.times, or something else -- or a += 1 if I absolutely must have a counter like that. -austin -- Austin Ziegler, austin@halostatue.ca on 2002.12.01 at 18.45.47