Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by YuckFoo (Abbot)
on Jun 23, 2009 at 14:24 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-19 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found