News for hackers. Stuff that matters.
Re:Algorithms in PHP: Deques by firasd on Tuesday September 13, 2022 @10:01AM (#32824400)
Actually this type of over-usage of ternary operators is not a PHP thing.. it's very prevalent in the JavaScript world
Re:Algorithms in PHP: Deques by jorams on Tuesday September 13, 2022 @10:39AM (#32824861)
None of those snippets contain a ternary operator.

?? is the Null Coalescing Operator[1]

?-> is the nullsafe operator[2]

[1]: https://www.php.net/manual/en/language.operators.comparison.... [2]: https://www.php.net/manual/en/language.oop5.basic.php#langua...

Re:Algorithms in PHP: Deques by firasd on Tuesday September 13, 2022 @01:32PM (#32827529)
Oh my mistake. Still stuff like 'return a || b' is the kind of thing I see in JS way more than in PHP codebases
Re:Algorithms in PHP: Deques by deergomoo on Tuesday September 13, 2022 @05:47PM (#32830565)
Probably because the Boolean operators in JS return the left or right side of the expression, rather than a Boolean.

It was an okay-ish way to get a default/fallback value before JS got a proper coalescing operator.