Re:What's new in PHP 8?
by kyleee on Thursday August 13, 2020 @09:41PM
(#24152221)
for some reason (probably a bad one) i love switch statements and i look forward to the match expression
[ Parent
| on HN ]
Re:What's new in PHP 8?
by __sisyphus__ on Thursday August 13, 2020 @11:19PM
(#24152889)
for whatever reason (also probably a bad one), i hate the syntax of switch statements, and for that reason i almost never use them. the match expression though, i'm actually very excited about. i quite like the mapped look; it seems more intuitive to read.
Re:What's new in PHP 8?
by systematical on Friday August 14, 2020 @12:21AM
(#24153337)
nothing wrong with switch statements.
Coerced-typed (weak) comparisons and easy accidental fallthrough are the problems commonly associated with switch statements.
The new match construct fixes both of these and is also an expression instead of a statement, allowing for more expressive code.