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

A switch or case statement is a restricted form of pattern matching for simple values. It fits those use cases, which are frequent.

I use a language that has both pattern matching and case constructs. I use both.

If you're doing complex pattern matching all over the place (especially matching the same sets of cases repeatedly in multiple locations in the code), maybe your design sucks. It's not making effective use of OOP or some other applicable organizational principle.



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

Search: