Rants on software, computing, and any other topic I feel like.
Tuesday, January 04, 2011
Switching on Boolean Conditions and Flags
I just posted an article over at CodeProject.com about what I call a boolean switch or switch flags (as the library I wrote is called). I've thought a lot about it over the years and implemented in a couple ways. It reduces the complexity of nested if statements. Basically, it allows for code like this:
switch_flags_2(a > b, c != d)
// only execute when "a > b" and "c != d"
// execute when "a > b" is false