3 ms·
Just curious, does match expressions have any advantage over using a hash (or in PHP terms an associative array)?
by boredtofears 5y ago
Just curious, does match expressions have any advantage over using a hash (or in PHP terms an associative array)?
- francislavoie 5y agoYeah, it's more like a switch but as an expression. Some more examples: https://php.watch/versions/8.0/match-expression https://php.watch/versions/8.0/match-expression It only executes the matching branch, ignoring the others. If you used an array/map + index, then it executes the right-arm of each of the options if they're functions for example, even if their result is thrown away.