Created
July 12, 2016 05:01
-
-
Save lamh85/eda9606a1f9abbd2d1bd009baf0fc577 to your computer and use it in GitHub Desktop.
Repetitive ORs
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
test_subject = "hello" | |
# Instead of doing repeptive ORs: | |
if test_subject == "hello" || test_subject == "world" || test_subject == "foo" || test_subject == "bar" | |
# do something | |
end | |
# Be more concise by using .include? | |
if ["hello", "world", "foo", "bar"].include?(test_subject) | |
# do something | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment