Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Useless use of string in return statement

by Anonymous Monk
on Apr 13, 2021 at 00:47 UTC ( #11131164=note: print w/replies, xml ) Need Help??


in reply to Useless use of string in return statement

Try immediate-if:  return $result{'message'} ? $result{'message'} : "$result{'api-key'}:$result{'session'+}";

Replies are listed 'Best First'.
Re^2: Useless use of string in return statement
by Your Mother (Archbishop) on Apr 13, 2021 at 15:06 UTC

    Every single line of code untenable…

    syntax error at - line 1, near "+}" Execution of - aborted due to compilation errors.
      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).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2021-05-17 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (154 votes). Check out past polls.

    Notices?