Hacker News new | ask | show | jobs
by hoppp 458 days ago
My first thought was to rewrite it without any or and operation. just return early from if statement.

If user is blacklisted return access denied; If account is expired return access denied; If no conditions match return access granted;

Wouldn't that be more effective?

1 comments

You are touching on an inherent truth in TFL, which is that there are nearly infinite equivalent statements for any logical sentence.

The idea for the article was to make a real example of logical equivalence, as books on the subject stay pretty abstract. - like others have mentioned, in the real world there are smarter choices to be made.