top | item 43940912

(no title)

bbatsell | 9 months ago

The HTTPStatus enum example is a good one, but the backtick syntax is _rough_. I would only ever use the Type.case form in practice. The test stuff is basically a way to create BDD-style test names, which is kind of just a preference thing. I can’t envision myself using it for anything other than weird case names (I already use case `default` quite a lot because it’s such a useful word), but maybe some interesting DSLs can come out of it? I would not have prioritized that change personally.

discuss

order

rTX5CMRXIfFG|9 months ago

The HTTP status enum example is a _terrible_ one. If you need to represent HTTP statuses and call them by their integer names, why not just pass the damn integer itself? It's exactly what you get in `HTTPURLResponse.statusCode`, and you can already `switch` against it. Already not looking forward to the code that undiscerning devs will mindlessly write just because someone with a huge following wrote a blog.

dagmx|9 months ago

You can’t exhaustively handle an enum with just an integer.

tiltowait|9 months ago

The backtick syntax for enums is rough, and typing out the full Type.case form negates one of Swift’s niceties (the ability to just type .case if the compiler can tell which enum is in use).

90s_dev|9 months ago

I would not have even approved it. But that's just me.