logoalt Hacker News

Tcepsatoday at 6:35 PM2 repliesview on HN

In the reserved case you do still need to check if you have a reserved entity, but you can put it (along with the other allowed "pseudotypes") in a switch/case block and have it just break back out immediately (the no-op mentioned in the article) rather than having to use a separate if/else to check for Null, or clutter things up with a try/catch wrapper.

Does that address what you're asking about?


Replies

SPascareli13today at 6:44 PM

But that assumes I have some switch case somewhere right? If I passed an array of "orders" to a downstream function, it knows that what it has is orders, not something else, so it doesn't need to check for anything, and in the case I checked for errors upstream (when I try to allocate a new order) all downstream functions know that no invalid order can be passed, in which case you only have one check at creation time.

That's why I haven't fully understood yet how working like this is simpler.

show 1 reply
sjducbtoday at 6:50 PM

Why is a try/catch wrapper clutter but a switch case is not?

show 1 reply