`if let` shorthand

How about if some foo { ... }. It's consistent with the .some case in Optional. The fact that let unwraps is magical and can be unintuitive. Teaching young programmers who aren't familiar with Optional I've always had to tell them "this is what let does here, it unwraps, you just have to know it. Yes, that's inconsistent with what let does outside of if and guard statements.". But if one teaches Optional from its cases none and some(Wrapped) then if some foo { ... } makes a lot of sense.

Only issue is the word some is being used to refer to protocols these days as well, like some View, but I think this is a different context.

3 Likes