Comment

Comment by elnygren

The point of the switch-case is to mimic pattern matching and TS is smart enough tell you whether you handled all cases.

Would you prefer that it's a if-elseif-else based structure instead? I guess that would work too but I feel like it could be easier to write it in a way where you accidentally forget to handle some case (since your else / last return is a potential catch-all).

I personally don't mind switch-case because I'm so accustomed to it in ReasonML/ReScript already.

parent elnygren 5 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton