Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I still think it is a shame that `match` isn't valid as an expression, requiring things like the helper function here that could be a lambda or part of a comprehension otherwise


The example absolutely can be done with conditional expressions (`x if y else z`). But each `case` of a `match` can execute arbitrary imperative logic (like `return`, `raise` etc.); a "match expression" syntax would have to support much less, and it's hard to imagine how it would gain any benefit over the existing conditional expression syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: