Array Slice Ranges

Bill Baxter dnewsgroup at billbaxter.com
Wed Nov 8 22:09:11 PST 2006


rm wrote:
> %u wrote:
>> I'm learning ruby right now, and I noticed they use a very cool syntax 
>> for ranges.
>>
>> 0..5 means 0, 1, 2, 3, 4, 5
>> 0...5 means 0, 1, 2, 3, 4
>>

> and I think ruby must change it <g> because 
> ... has one point more than .. but one element less ... (these latest 3 
> points indicate I could go on and on ... :-) )
> 

Whoa!  I skimmed the ruby docs about .. vs ... a while back and I 
remember thinking "hey that's really cool, and easy to remember too 
because ... goes farther than .."  I guess it was just so obvious to me 
that that would be their meaning that I didn't realize that Ruby had it 
backwards.  Plus non-inclusive is generally more used in programming 
languages with 0-based indexing.  The shorter thing should be the more 
common.  It made total sense to me.

But I was wrong.  Ouch.  Ruby really flubbed that one.

Well D certainly won't make that mistake, because .. is already too 
entrenched as non-inclusive.  :-)

--bb



More information about the Digitalmars-d mailing list