Skip to content

Instantly share code, notes, and snippets.

@lamh85
Created July 12, 2016 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamh85/eda9606a1f9abbd2d1bd009baf0fc577 to your computer and use it in GitHub Desktop.
Save lamh85/eda9606a1f9abbd2d1bd009baf0fc577 to your computer and use it in GitHub Desktop.
Repetitive ORs
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