Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Value of a statement with modifier

by LTjake (Prior)
on Jan 22, 2007 at 18:18 UTC ( #595959=note: print w/replies, xml ) Need Help??


in reply to Re: Value of a statement with modifier
in thread Value of a statement with modifier

A small quibble, but I believe the first example should be written as:

return $_[ 0 ] ? () : 'hello';

--
"Go up to the next female stranger you see and tell her that her "body is a wonderland."
My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
" (src)

Replies are listed 'Best First'.
Re^3: Value of a statement with modifier
by hossman (Prior) on Jan 23, 2007 at 02:40 UTC

      Returning undef for false is more broken than returning empty lists for false. At least an empty list is easily promoted to a false or undef value but an undef value in a list is not as easily demoted to a false value. I think all the people returning undef for false are shortsighted and I hope they never get their hands on my code.

      sub empty {} if ( empty() ) { ... } # ok @foo = empty(); if ( @foo ) { ... } # ok sub returns_undef { undef } if ( returns_undef() ) { ... } # ok @foo = returns_undef(); if ( @foo ) { ... } # NOT OK if ( grep { defined } @foo ) { ... } # oh ok, now it's "better".

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://595959]
help
Chatterbox?
[msh210]: doesn't append anything.
[msh210]: It should say "If the last nonempty element of LIST" or "If the string thus to be printed does not end in a newline""
[msh210]: Am I wrong?
[shmem]: no. You're right.
[msh210]: About time... last time I was right was... I don't even remember when.
[shmem]: perl -e 'warn "test$/", ^@^ '
[Eily]: well, at least it's right about warn doing the same thing as die :)
[shmem]: same with undef as last element
[msh210]: oh, good point. It's the best kind of correct
[shmem]: msh210: but I'd not call it a lie outright. That's when you do know the truth.

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (19)
As of 2017-04-24 12:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.