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

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.)

Replies are listed 'Best First'.
Re^4: Useless use of string in return statement
by haukex (Archbishop) on Apr 13, 2021 at 15:50 UTC
    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).

        nor would it be necessary for the point (i.e. the OP's problem).

        True, but if you're going to be nitpicky and mention tied variables, then better go all the way ;-)