Live data from Hacker News

Clearer Conditionals using De Morgan's Laws

robots.thoughtbot.com

1–10 of 82 posts

Re: Clearer Conditionals using De Morgan's Laws

#2
Good naming conventions are pretty key here. My guess is the original writer of that code had used those in something else entirely, then reused those methods in a new method so he wouldn't have to rewrite.

I always feel like it's better to positively name Boolean values, personally, but I know everyone is different.

Re: Clearer Conditionals using De Morgan's Laws

#7

Cool to see De Morgan's Laws used at a high level. But the real takeaway: rewrite your conditional until it makes sense.

Or conversely that it is better to write affirmative conditionals rather than negative conditionals. I always find reading the affirmative ones much easier, as I have always found working in positive logic easier than work with negative logic circuits.
Post reply on HN