Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: I've never seen this syntax before

by Anonymous Monk
on Apr 05, 2001 at 00:41 UTC ( [id://69881]=note: print w/replies, xml ) Need Help??


in reply to Re: I've never seen this syntax before
in thread I've never seen this syntax before

return 0; should be return "";

Replies are listed 'Best First'.
Re: I've never seen this syntax before
by cLive ;-) (Prior) on Apr 05, 2001 at 01:02 UTC
    It doesn't matter. I can return "0", 0, or "" for false. They are equivalent in a boolean context.

    cLive ;-)

      You're right, they are equivalent in a boolean context, but they are not equivalent. Your post implied that not and ! would return 0 and that is incorrect.
(tye)Re: I've never seen this syntax before
by tye (Sage) on Apr 05, 2001 at 19:50 UTC

    Actually it is more subtle than even that. You can't replace !1 with 0 nor with "".

    0 is wrong because, in a string context, !1 is "" while 0 is "0".

    "" is wrong because, when warnings are turned on, 0+"" generates q(Argument "" isn't numeric) while 0+!1 is silent.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-25 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found