3 ms·
> That people will just init nonsense objects to get around the warnings. You technically can do "= null!", which means assign null by default, but assume it i
by Deukhoofd 4y ago
> That people will just init nonsense objects to get around the warnings.
You technically can do "= null!", which means assign null by default, but assume it is not null. This is currently the recommended way to do deserialization, where you know the value is not null, but you have not explicitly filled it.
- AtNightWeCode 4y agoNo, you get a nullable warning for that as well. You also need to change the reference type to nullable. I am convinced that some people will just init the properties with new(). And by that hide the null errors. Easily the hardest bugs to track down is when things fails long after the real error occur. I think they could have come with a better solution to the problem.
- Deukhoofd 4y agoIf you assign it with "= null", you get the warning. If you assign it with "= null!" (note the exclamation mark, the null-forgiving operator), you do not.
- AtNightWeCode 4y agoOk, correct. I did not know about that. Thanks for the clarification.