4 ms·
Is pattern matching a generalization of if/then/else, a reframing of it, or something else entirely?
by eat_veggies 6y ago
Is pattern matching a generalization of if/then/else, a reframing of it, or something else entirely?
- colejohnson66 6y agoI see it as a cross between a switch and if statement. You’re saying based on what `x` is (a switch), do these things that a switch can’t do (an if).
- alew1 6y agoIf-then-else is pattern matching on a value of type Bool. I think of general pattern matching on algebraic data types as a generalization.