Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
eat_veggies
· 5y ago · 0 comments
Is pattern matching a generalization of if/then/else, a reframing of it, or something else entirely?
Comments
[–]
colejohnson66
5y ago
I 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
5y ago
If-then-else is pattern matching on a value of type Bool. I think of general pattern matching on algebraic data types as a generalization.