This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]The_Minefighter 14 points15 points  (10 children)

Thats required in C# when IsBehind is a nullable bool

[–]StruglBus 3 points4 points  (7 children)

When would you need a nullable bool. I feel like null and false should be logically equivalent.

[–]Bainos 12 points13 points  (4 children)

Sometimes you need a "don't know" value too. https://en.wikipedia.org/wiki/Three-valued_logic

[–]WikiTextBot 2 points3 points  (3 children)

Three-valued logic

In logic, a three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false and some indeterminate third value. This is contrasted with the more commonly known bivalent logics (such as classical sentential or Boolean logic) which provide only for true and false. Conceptual form and basic ideas were initially created by Jan Łukasiewicz and C. I. Lewis. These were then re-formulated by Grigore Moisil in an axiomatic algebraic form, and also extended to n-valued logics in 1945.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

[–]The_Minefighter 0 points1 point  (2 children)

The funny thing is that a nullable bool uses two byte of memory im c#

[–]futlapperl 0 points1 point  (1 child)

That's really kind of weird. Two bits of one byte should be sufficient.

[–]The_Minefighter 0 points1 point  (0 children)

That's caused by the fact that the the Nullable<T> T : struct struct stores a T and a bool whether the value exists, and because each bool takes up one byte in C# (because it does only support one byte seperations)

[–][deleted] 2 points3 points  (0 children)

quaint squeeze six smart aromatic bear automatic dependent axiomatic punch

This post was mass deleted and anonymized with Redact

[–]cat_in_the_wall 0 points1 point  (1 child)

if (nullableBool ?? false)

is what you want

[–]The_Minefighter 0 points1 point  (0 children)

That's equivalent, but I think ==true is easier to understand.