I love the new pattern matching with match/case, and anticipate using it heavily. What I’m not so keen on is the “match everything else” at the end (case _).
Why couldn’t a hard, “final” case be added such as this:
match myval:
case 1:
return 'One'
case 2:
return 'Two'
finally:
return 'No value given'
I feel like this has two benefits:
- It matches other control flow that has a “final” case, such as
if/elif/elseandtry/except/finally. - It could enforce that there are no further conditions added after it, that will never be reached… with
case _, it would be easy to add another case beneath that without thinking.
case _ could still work, but something like finally would be available and more accepted? maybe?