Created
November 15, 2012 14:28
-
-
Save pallan/4078881 to your computer and use it in GitHub Desktop.
Nested if statements without else conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if a || b == d || c != n # lets check a bunch of conditions | |
if m <= p && a > n # we passed! ok, let's check some more | |
puts 'YAY' # we passed again! | |
end # I guess that's all we really needed | |
end # fine! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I agree, and if the conditional logic is that complex, why not extract it into a method? Here's another that boiled my blood:
though when I first saw this, it was written in PL/1:
though to be fair, this was from a programmer who still used GOTOs at the time. The worst was when they would GOTO into or out of the middle of a subroutine, no one could ever explain to me what happened to the call stack when this happened... I'm so glad it's not the early 90s anymore.