Saturday, March 19, 2011

2-valued boolean variable

What do you name a variable that is a boolean but can have 2 meaningful values out of N?

Example: x can have values "red" or "blue".

Calling it bRed, or isRed, is meaningful if he value is true , but doesn't convey any info about the "false" case.

YOu could implement it as an int, or if you are picky, as an enum. But this means more lines of code to declare the enum, etc.

I thought of "redOrBlue", but logically speaking, the value is always true :)

What do you think of "redNotBlue"? Any better ideas?

No comments:

Post a Comment