Hacker News new | ask | show | jobs
by unnah 301 days ago
How about a situation where the inner Optional<T> is acquired from another system or database, and the outer Optional<Optional<T>> is a local cache of the value. If the outer Optional is null, then you need to query the other system. If the outer Optional is filled and the inner Optional is null, then you know that the other system explicitly has no value for the data item, and can skip the query. Seems like using nested optionals would be natural here, although of course alternative representations are possible.
1 comments

what is the advantage of using that over 2 variables? the cost is extra mental load, what does it buy?