SE-0230: Flatten nested optionals resulting from `try?`

I guess I don't understand why this should be baffling, especially if you rewrite it in a more user-friendly form:

try? (...) -> T? returns T?
try? (...) -> T returns T?

That makes the next line easy: check for a nil, otherwise you have a T.

But when that is actually this:

try? (...) -> U? returns U??

the next line is no longer easy. One unwrap is no longer enough, and the if test is now multi-partite, and which unwrap means what, and do I care which is which, and … and … suddenly it's baffling.

If (as you said) you think optionals are a stumbling block to understanding, double optionals are IMO exponentially worse harder.

2 Likes