Showing posts with label nullable types. Show all posts
Showing posts with label nullable types. Show all posts

Thursday, 19 February 2009

Nullable<bool>


I don't like Nullable<bool>. The cognitive dissonance is louder and more dissonant than a Sepultura guitar solo. [3'00]

A boolean is defined as: "Of or relating to a data type or variable in a programming language that can have one of two values, true or false."

Two. Deux. Zwei. Dos.

TWO!

Not three.

But that is what exactly Nullable<bool> is. True, false and null. Three states.

What does null mean? It's got to mean something. You're either pregnant or you're not. You can't have a third state. A light switch is either on or off.

If a light switch doesn't exist then it's potentially very dangerous. Almost as dangerous as having a nullable bool.

If it has three states, it isn't a bool.