29 ms·
but why all of a sudden languages started to add this? Maybe the function itself needs to be simplified, maybe there is a design issue. i am failing to see how
by yetkin 6y ago
but why all of a sudden languages started to add this? Maybe the function itself needs to be simplified, maybe there is a design issue. i am failing to see how "if else" can be simplified via a synth sugar.
- beberlei 6y agoone benefit of match over switch is that it uses === and not == internally. So it does not suffer from type coercion problems.
- nicoburns 6y agoIt's a switch statement that's an expression. That's a nice ergonomic improvement when you want to assign the result to a variable. Especially as it allows you to use a non-mutable variable whereas otherwise you'd have to make it mutable.
- chmod775 6y agoI wouldn't compare it to a switch statement, because a switch statement - even though it looks similar - has fundamentally different control flow.
- deleted 6y ago[deleted]