3 ms·
Person should have type Person, and null should have type Null. Then the compiler could make sure you didn't ever mix the two up! But I guess that ship sailed
by mrkeen 6y ago
Person should have type Person, and null should have type Null. Then the compiler could make sure you didn't ever mix the two up! But I guess that ship sailed a while ago, and enough has been written on the matter.
I think I dislike `is not` though, mostly because `!=` still exists so now there's two of them. I already use the wrong null check in SQL[1], I don't want to use it in C# too.
[1] https://stackoverflow.com/questions/5658457/not-equal-operator-on-null https://stackoverflow.com/questions/5658457/not-equal-operat...
> To compare if your value is not null, you use IS NOT NULL, while to compare with not null value, you use <> 'YOUR_VALUE'. I can't say if my value equals or not equals to NULL, but I can say if my value is NULL or NOT NULL. I can compare if my value is something other than NULL.
- nikeee 6y ago> think I dislike `is not` though, mostly because `!=` still exists so now there's two of them. Note that "!= null" may behave differently than "is not null". != is an operator that can be overloaded, "is not" is not. Same counts for "is" and == when checking for null.
- Guillaume86 6y ago> Person should have type Person, and null should have type Null. Then the compiler could make sure you didn't ever mix the two up! But I guess that ship sailed a while ago, and enough has been written on the matter. You can somewhat get that in C# nowadays: https://docs.microsoft.com/en-us/dotnet/csharp/nullable-references https://docs.microsoft.com/en-us/dotnet/csharp/nullable-refe...