3 ms·
I always advocated for this kind of change in C# and now I'm using Swift I'm definitely sure that non-nullability should be available in any kind of OO-language
by dep_b 11y ago
I always advocated for this kind of change in C# and now I'm using Swift I'm definitely sure that non-nullability should be available in any kind of OO-language. There aren't that many use cases that require nullability of a reference and there are many cases where the forced nullability bites you.
Unfortunately adding it to C# now will mean that either the language breaks or the feature will be an add-on that isn't as powerful as it should be (like in Swift, where it's really the base for everything).
Personally I would say that a reference type can be declared explicitly non-nullable with an exclamation mark (!) and if they're properties they either should have a default value or they should be set while the class is constructed.