Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: return !!

by jwkrahn (Monsignor)
on Mar 04, 2009 at 20:06 UTC ( #748306=note: print w/replies, xml ) Need Help??


in reply to return !!

The same as:

return @value ? 1 : '';

Replies are listed 'Best First'.
Re^2: return !!
by ikegami (Patriarch) on Mar 04, 2009 at 20:32 UTC

    Not quite.

    $ perl -wle'print 0 + sub { my @v; !!@v }->()' 0 $ perl -wle'print 0 + sub { my @v; @v ? 1 : "" }->()' Argument "" isn't numeric in addition (+) at -e line 1. 0

    And it doesn't return zero for false either.

    $ perl -wle'print "" . sub { my @v; !!@v }->()' $ perl -wle'print "" . sub { my @v; @v ? 1 : 0 }->()' 0

    False is actually dualvar(0, '')

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2023-06-10 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (39 votes). Check out past polls.

    Notices?