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

Re: why the array index has to start at 0??

by YuckFoo (Abbot)
on Jun 23, 2009 at 14:24 UTC ( #774038=note: print w/ replies, xml ) Need Help??


in reply to why the array index has to start at 0??

It's works cleanly with so many constructs, like ...

with mod operator, for ring buffers:

$buffer[$i++ % $SIZE] = $foo;
with rand():

$pick = $array[rand(@array)];
I'm sure we could come up with many others. Natural, no?

ZeroFoo


Comment on Re: why the array index has to start at 0??
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (21)
As of 2014-10-20 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (88 votes), past polls