DEV Community

Discussion on: Unhealthy Code: Null Checks Everywhere!

Collapse
 
jamesmh profile image
James Hickey

Sure. There's a semantic preference and also, in some cases, a performance boost too.

In C#, for example, using Enumerable.Empty<T>() will use a singleton underneath the covers so you aren't allocating an empty array on the heap.

In very specific situations that could help. Otherwise, it's mostly a semantic preference.

Collapse
 
petergabriel2 profile image
PeterGabriel2

That enumerator was not good example. You can't compare mutable with immutable - in this case it is not about semantic.