3 ms·
This is great! TypeScript (another Microsoft language) did something similar not long ago but used a flag to opt-in to strict null checks. It seems this setting
by styfle 9y ago
This is great! TypeScript (another Microsoft language) did something similar not long ago but used a flag to opt-in to strict null checks. It seems this setting is strongly encouraged.
Looking at the examples, the compiler can determine if not null by reading the if statement like so
if (str != null)
But what about if the code uses the following?
if (!string.IsNullOrEmpty(str))
TypeScript has a way to solve this using the `is` keyword but I'm not sure if this is introduced in C# yet.