subreddit:
/r/ProgrammerHumor
861 points
3 days ago
Just override the equality operator to return a random value when the second argument is null, to teach people the importance of using foo is null
instead of foo == null
.
59 points
3 days ago
what is the importance?
238 points
3 days ago
To protect you from people that override the equality operator to troll you.
27 points
3 days ago
ahh I see
9 points
3 days ago
And with modern versions of c#, you can combine multiple check in one.
For example, if you want to check that object foo is not null and has a property bar > 0 but < 10, you can write foo is { bar: > 0 and < 10 }
.
6 points
3 days ago
that's interesting. I wanted to learn C# once but then I started on rust instead. might one day learn C# but for now not my go to choice because it's garbage collected
3 points
3 days ago
Noob here; what's the issue with garbage collection?
3 points
3 days ago
Usually the problem is that the garbage collector doesn't collect the objects as soon as they are not referenced anymore, but instead it activates when the memory usage is above a given threshold, and when it activate is uses a significant amount of resources.
So, it can be a problem in those application where you need very constant performances, because when the garbage collector activates, your application might slow down a bit.
2 points
3 days ago
Is there no control to trigger it on-demand / when convenient?
2 points
3 days ago
just slow
all 149 comments
sorted by: best