Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Useless use of string in return statement

by Your Mother (Archbishop)
on Apr 13, 2021 at 15:06 UTC ( [id://11131188]=note: print w/replies, xml ) Need Help??


in reply to Re: Useless use of string in return statement
in thread Useless use of string in return statement

Every single line of code untenable…

syntax error at - line 1, near "+}" Execution of - aborted due to compilation errors.

Replies are listed 'Best First'.
Re^3: Useless use of string in return statement
by Anonymous Monk on Apr 13, 2021 at 15:44 UTC
    Not to mention that return $a ? $a : $b; can always* be written as return $a || $b; ... which is exactly what tybalt already said.

    (*unless $a is tied.)
      Not to mention that return $a ? $a : $b; can always* be written as return $a || $b;

      Nitpick: $a and $b should not be understood as stand-ins for "anything", since @a || @b is not the same as @a ? @a : @b, since the former imposes scalar context on @a (and not on @b).

        $a and $b should not be understood as stand-ins for "anything"

        True. I very consciously chose the scalars $a and $b. In fact, I had originally started to write return A ? A : B; but realized that that would not be sufficient, nor would it be necessary for the point (i.e. the OP's problem).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found