Why are there no lifted short-circuiting operators on `bool?`?

What you propose would create two different usage patterns for nullable types.

Consider the following code:

bool? a = null;

// This doesn't currently compile but would with lifted true/false operators.
if (a)
{
}

// Whereas this provides a consistent use of nullable types.
if (a ?? false)
{
}

For consistency in the usage of nullable types, it makes sense to not lift the true and false operators on bool. I don’t know if this is the real reason why it wasn’t done, but it makes sense to me.

Leave a Comment