3 ms·
The ugly solution is Swift's if let x = x which is literally the same check, but in a more verbose manner. Yes, compilers should be able to help in this and ma
by troupo 3y ago
The ugly solution is Swift's if let x = x which is literally the same check, but in a more verbose manner.
Yes, compilers should be able to help in this and many other cases, and not just give up and force the programmer to do all the unnecessary manual work
- saagarjha 3y agoIt’s not a check, it’s binding a new variable with a different type (which may or may not have the same name; if it does you can use if let x these days). And solving the other examples I mentioned is generally out of the realm of most programming languages in use today (except maybe TypeScript?) It comes with significant challenges that I’m not sure we are ready to address properly yet.