Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
The stupid question is the question not asked
 
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 chilling in the Monastery: (4)
As of 2014-04-19 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls