logoalt Hacker News

david2ndaccount • today at 3:23 AM • 1 reply • view on HN

The answer is they don't in practical code but they come up in generic code, where you want to wrap something that is already returning an optional in your optional. In languages that do support optional[optional[whatever]], if you every actually write that you know you've messed up your API.


Replies

masklinn • today at 6:44 AM

They absolutely do in practical non-generic code. A case I personally encounter regularly is json APIs which distinguish between a key being missing and one being set to null in a structure.