|
|
|
|
|
by rlander
3869 days ago
|
|
You can use, for example, elaborate if-else constructs that firstly try to determine type of the value, then check for values. That's nowhere near pattern matching. Two concepts make pattern matching vastly superior to if-else constructs: - Non-exhaustive checks by the compiler. - Destructuring |
|
It's being a combination of destructuring, branch selection and variable assignment that makes pattern matching superior.