Array indexing and slicing

Hong Hong_member at pathlink.com
Mon Apr 3 13:30:56 PDT 2006


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.





More information about the Digitalmars-d mailing list