Hacker News new | ask | show | jobs
by rTX5CMRXIfFG 408 days ago
Either you’re unaware or you’re arguing in bad faith, but you can switch against integers and pattern-match within integer ranges. The consequences of receiving an unexpected status code is the same—you handle it in the default case, as you would when decoding to an HTTPStatus enum fails.
1 comments

Way to start of the comment by being uncivil. You could have made the exact same point without being a jerk about it.

But it’s common to only want to support specific response codes in a context, and people do use enums for that. It’s a fairly common paradigm, and an enum will do all those validations for you so you don’t forget.