4 ms·
Nullable reference without "if let" keyword is disaster
by bernadus_edwin 9y ago
Nullable reference without "if let" keyword is disaster
- hungerstrike 9y ago"If let" leads to code that is hard to read IMO. I'd rather be able to easily tell the difference between conditional statements and assignments. Another Swift feature that I think leads to very poor readability is trailing closures.
- bernadus_edwin 9y agoWithout if let, you must add one line for declare local variable. And also must add exclamation mark
- MadsTorgersen 9y ago"If let" could be easily mirrored by a pattern in C#, and we are starting to discuss that. However, that's a new way to check for null in the language, where what we need is to recognize the ways people are already checking for null in billions of lines of code. Therefore, the priority is to do a good flow analysis that will just understand when a nullable variable can be assumed to not be null (e.g. after a check, a non-null assignment, etc.), and then let you dereference without challenge.
- bernadus_edwin 9y agoIf c# 8 has good flow for checking null, then no need "if let". If let also has disadvantage, backward compartibility. For example, maybe i want change my logic class to c# 2
- wuzzard 9y agoC# 7.0 already has the 'is' pattern matching operator that returns true/false and can introduce a new variable that is not null.