3 ms·
> They couldn't have fixed it while retaining backward compatibility. Opt-ins exist. That's what .net ended up doing: by default the language uses "ubiquitous"
by masklinn 4y ago
> They couldn't have fixed it while retaining backward compatibility.
Opt-ins exist. That's what .net ended up doing: by default the language uses "ubiquitous" nullability, but you can enable reference nullability support at the project or file level.
If you do that, references become non-nullable, and have to be explicitly marked as nullable when applicable.
- wizofaus 4y agoThe smart thing that C# has though is automatic conversion to non-nullable references, e.g.: void foo1(Bar bar) { ... } void foo2(Bar? bar) { if (bar != null) foo1(bar); } Which wouldn't compile if you didn't have the `if` condition.