Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: what would you like to see in perl5.12? (trees)

by Arunbear (Parson)
on Aug 05, 2008 at 13:29 UTC ( #702358=note: print w/ replies, xml ) Need Help??


in reply to Re: what would you like to see in perl5.12? (trees)
in thread what would you like to see in perl5.12?

What should the 'seek' function do if you seek to a non existent key?


Comment on Re^2: what would you like to see in perl5.12? (trees)
Re^3: what would you like to see in perl5.12? (seek)
by tye (Cardinal) on Aug 05, 2008 at 14:35 UTC

    'seek' doesn't care whether the key exists or not. It just arranges for the next use of each (actually, adding a way to reverse 'each' would be prudent as well) finds the earliest key greater than or equal to the key given to 'seek'. For convenience of interface, 'seek' might return something which might be different depending on whether the requested key exists or not, but those are details best left to the (unknown) implementor.

    - tye        

      But say you have a hash like
      %capital = ( France => 'Paris', England => 'London', Hungary => 'Budapest', );
      and you seek to 'Russia'. Should the next call to each behave as if all the elements had been read (i.e. return end-of-hash) ?

        Of course.

        - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-12-22 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (112 votes), past polls