Type narrowing

There have been several discussions in the past about this feature:

November 2016:

October 2020:

September 2022:


Notably, in the Nov 2016 thread, Chris Lattner wrote:

There were also questions about how it would interact with overload selection, how it would work with stored class properties (that might get changed while your code is running), and how it would work with computed variables.

Personally, I’ve never really wanted a feature like this. if let works fine for me. I’ve never used a language with this feature before, though, so maybe I just don’t know the benefits.

3 Likes