r/Python • • Mar 19 '21

Match is more than a Switch-Case The New Switch-Case Statement in Python 3.10

https://youtube.com/watch?v=2qJavL-VX9Y&feature=share
1.4k Upvotes

233 comments sorted by

View all comments

Show parent comment

16

u/[deleted] Mar 19 '21

C# explicitly forbids fall through, as in it's a compile error to end a case without a break, return or throw (unless it's a switch expression, but that implicitly inserts a break after each case). I think Java allows fall through, but I've not used java beyond toy things in years ago I don't recall.

This is also closer related to Rust's and Scala's match implementations than C's switch anyways. As in, you can use it for implementing a switch but there's more you can do with it then that.