Array indexing and slicing

Luís Marques luismarques+spam at gmail.com
Mon Apr 3 14:09:49 PDT 2006


In article <e0s0m0$1mp9$1 at digitaldaemon.com>, Hong says...
>
>In article <e0rmga$1bi6$1 at digitaldaemon.com>, Luís Marques says...
>
>>notation and someting you'd expect to find in Perl. I still prefer it to the
>>more verbose "a[2 .. a.length]" notation, though. The verbose notation has the
>>disadvantage of taking more whitespace; while most people read "a[2..3]" just
>>fine it's a bit confusing to read "a[1..a.length]". Also, if you rename or use a
>>different array you have two instances to correct, instead of one.
>>
>
>You can do a[1..length]. length always refer to the array length when it is used
>inside the indexing operator. So there is only 1 place to correct when you
>change the array name. length is more verbose but definitely more readable.

Oh yes, I was forgetting that variant. That's nice, thanks.
Perhaps one more reason against having $, though I guess several will disagree.

Luís



More information about the Digitalmars-d mailing list