Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^7: Dumb, non-question: How to return 'nothing'.

by BrowserUk (Pope)
on Jun 18, 2011 at 07:31 UTC ( #910309=note: print w/ replies, xml ) Need Help??


in reply to Re^6: Dumb, non-question: How to return 'nothing'.
in thread Dumb, non-question: How to return 'nothing'.

The point was that while( my $next = $iter->() ) { ($next) = @$next; ... } is a complicated version of while( my $next = @{ $iter->() } ) { ... }

Not so. In the latter case when the iterator returns undef to terminate iteration, you will attempt to dereference that undef causing an error.

In the former, the loop terminates and the dereference is never reached.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^8: Dumb, non-question: How to return 'nothing'.
by ikegami (Pope) on Jun 18, 2011 at 10:12 UTC

    you will attempt to dereference that undef causing an error.

    ug, tired. Will strike that bit.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2016-06-27 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (348 votes). Check out past polls.