3 ms·
How could you leave out left-associative ternary operators?
by RobotToaster 5mo ago
How could you leave out left-associative ternary operators?
- userbinator 5mo agoThat's exactly what I was expecting to read about upon seeing the article title. But apparently they deprecated and then changed(?!) the associativity in the past few years, which if anything just makes things even more confusing.
- moebrowne 5mo agoThis changed 6 years ago in 8.0, a major version change. Once again showing how out of date peoples hate for PHP is
- RobotToaster 5mo agoTo be fair mine and a lot of people's reaction to getting bitten by this was completely avoiding ever using the ternary operator in PHP.
- guskel 5mo agoSo it became sane as soon as late 2020.
- chuckadams 5mo agoTernary was made non-associative in 8.0, so it requires parentheses. It will become right-associative in 9.0. But there’s not much use case left for nested ternaries in PHP since the `match` operator was added in 8.0.