Skip to content
Advertisement

How to access the matched value in the default case of structural pattern matching?

With Python 3.10’s match statement, is it possible to use the value met in the default case?

Or does this need to be assigned a variable before match so it can be used in the default case?

JavaScript

Advertisement

Answer

You can use an as pattern:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement