Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: Perl is more intuitive

by kiat (Vicar)
on Aug 19, 2005 at 11:44 UTC ( #485082=note: print w/ replies, xml ) Need Help??

in reply to Re: Perl is more intuitive
in thread Perl is more intuitive

That looks very clean. And I supposed the each is a good-enough contextual clue that a hash is being called.

Comment on Re^2: Perl is more intuitive
Re^3: Perl is more intuitive
by Joost (Canon) on Aug 19, 2005 at 11:57 UTC
    each is actually a method name that's used for many of the container types; arrays use it too:

    arr.each { | x | # iterates the elements, NOT the index puts x }

    Basically, each here is just a method that recieves a block (like perl's anonymous subroutines) as an argument. The container type is then responsible for calling the block for each element.

    Any class can provide it's own each method - this is not a built-in function like perl's foreach.

      Ah, I see.



        Take this simple function:




Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://485082]
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-26 08:43 GMT
Find Nodes?
    Voting Booth?

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

    Results (168 votes), past polls