You added more syntax then needed. "-" has higher precendence then
"...".
(0..x.size-1).each
That appears quite clean and it only one more character then:
(0...x.size).each
And it works today with no changes, so you can start using it
immediately while those of us that like ... keep using it.
There's a pretty big irony in the two thread flying by on Ruby Talk
right now. They're really the same thing. Even better, I'm sitting
over here reading the release notes to the new Java 1.5 (sorry, it's my
job).
For those of you who don't know, Java just got some fancy new features
like Generic Types, Autoboxing for Primitives, Variable Length
Parameter Lists for Methods, etc. I keep expecting to see Larry Wall
or matz in the credits somewhere.
I guess we could examine all those features too, see if we really need
them. Java has sure made it a LONG way without them. They finally
added them though, to give developers a choice. Make the easy things
just a little bit easier. Choice is good, I think.
I like it that a..b-1 is the same as a...b. It means I can choose what
I'll use. collect() is the same as map() too, as are size() and
length(). Would you believe I actually use both? I've caught myself
using size() when I think it's closer to my meaning and length() when I
feel it is, though I have know idea how I decide this, their meanings
being so close. I just choose.
We could take away that choice I guess, but you'll have to take away
alias too, or I could put it back. And then even without alias, I
could add the method to the needed class myself, calling the alias.
Failing that, I guess I could just hack the Ruby interpreter... Wow, I
have a lot of choices.
The similar methods are documented together, so I really think this is
hard to miss. You can learn one and basically ignore the other, until
you read it in someone's code, then you'll learn, "Oh, collect() is
just another name for map(), which I already know."
I'm a fan of choice. I don't think we should introduce 10 aliases for
each method, but a few here and there to appeal to a wider audience is
a really nice touch, I think. a..b-1 is also a...b. Nifty, use the
one you can remember and/or like better. I think we should support
choice, not take it away. The Java team is starting to get it, so I
say there really must be hope for us all. Just my two cents, for both
threads.
James Edward Gray II
P.S. If it's not obvious, this message is NOT about whether or not ..
and ... are backwards, unless you're position is that we should just
kill ... to fix it. Do I think they're backwards? Haven't really
thought about it, which to me means it isn't painfully wrong. Should
we swap them? No, I would be against trading any two pieces of syntax
to exact opposite meanings at this point. Again though, this is a
separate issue to me.
P.P.S. Those of you who use collect() are wrong!