[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Range three dots (was Re: Range#length?!?!?

georgesawyer

2/5/2005 11:57:00 AM

"Hal E. Fulton" <hal9000@hypermetrics.com> Feb 13, 2003 at 06:45 AM wrote:
>"Yukihiro Matsumoto" <matz@ruby-lang.org> February 12, 2003 at 9:48 AM
wrote:
>>on 03/02/13, Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:
>>>This has always puzzled me, that the longer gap ('..' vs '...') is the
shorter interval, but it's way too late to change now, and knowing what I
know of Matz's work, there's going to be a VERY good reason for this!

>>Unfortunately not for this case. ".." was there first, so only "..."
was available when I wanted end excluding range. I made up the reason that
".. would be used more often, so that it should be shorter", but I myself
does not feel this is very good reason.

>I would rationalize it this way: .. works the same as in Pascal (the only
language I know that also has this construct, though there are probably
others). So the newer behavior gets the newer syntax (...).

>Maybe two weak reasons can be combined to make a stronger one... ;)

I remember it as, the third dot generally is a placeholder for the highest
inclusive value of the range.

With kind regards,

2 Answers

dblack

2/5/2005 1:14:00 PM

0

Martin DeMello

2/5/2005 5:00:00 PM

0

David A. Black <dblack@wobblini.net> wrote:
>
> My mneumonic is:
>
> .. has two letters, so the upper value is "in"
> ... has three, so the upper value is "out"

I think of the third dot as the "exclude end" switch (:

martin