Re: why is 0 first?
And here I thought it was just because 0 comes before 1 ;-)
On 27 Dec 2005, at 07:16, Adriano Ferreira wrote:
I am curious what the reasoning behind the first element of
something being zero is ($array[0]). I know I've read it before, but
I can't remember. Thanks!
Using indices 0 .. n make it possible to work with them like offsets
from the beginning of the array. More important from a C point of
view, where it may even improve performance. Ah, and for loops are
shorter by one character ;)
for ( $i=0; $i<$n; $i++ ) { .. }
rather than
for ( $i=1; $i<=$n; $i++ ) { ... }
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>
.
Relevant Pages
- RAID5 in three easy steps
... You know, after reading all the howtos and such, I created a RAID 5 ... array with just three commands ... I know that managing the array and recovering from a failure is more ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... (Debian-User) - Re: [opensuse] Are there ANY compelling reasons to upgrade to 11.0?
... Its been my experience that there are fewer bugs in later point ... releases than in any point Zero release. ... To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx ... For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx ... (SuSE) - Re: items in array
... Is $#array deprecated or not? ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ... The number of items in an array is returned by @array in scalar context, ... (perl.beginners) - Re: items in array
... I used to use $#array ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ... The number of items in an array is returned by @array in scalar context, ... (perl.beginners) - Re: items in array
... I used to use $#array ... To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx ... For additional commands, e-mail: beginners-help@xxxxxxxx ... scalar @array ... (perl.beginners) |
|