Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: why the array index has to start at 0?? (Perl!)

by Argel (Prior)
on Jun 24, 2009 at 19:03 UTC ( #774486=note: print w/ replies, xml ) Need Help??


in reply to Re^2: why the array index has to start at 0?? (Perl!)
in thread why the array index has to start at 0??

Except wouldn't that be:

for my $i ( @array )
?

Elda Taluta; Sarks Sark; Ark Arks


Comment on Re^3: why the array index has to start at 0?? (Perl!)
Download Code
Re^4: why the array index has to start at 0?? (Perl!)
by tye (Cardinal) on Jun 24, 2009 at 20:04 UTC

    Yes, (but s/\$i/\$e/ :) we are even more likely to avoid indices altogether in Perl. But how we avoid using indices casts little light on how indices should be defined, so it doesn't really apply to my argument. It helps with the "we don't care as much in Perl" point. Since it is all academic at this point, I'm less concerned with how "important" it is which index scheme fits Perl best.

    - tye        

Re^4: why the array index has to start at 0?? (Perl!)
by ikegami (Pope) on Jun 24, 2009 at 20:05 UTC
    Iterating over the elements is obviously preferred, but it's not always possible. Sometimes, you need to iterate over the indexes.
      Of course, but tye is using examples that undermine his own arguments!! I'm still going to go with just think "offset" when you see "index".

      Elda Taluta; Sarks Sark; Ark Arks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://774486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-08-02 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls