Skip to content

Instantly share code, notes, and snippets.

@lamh85
lamh85 / repetitive_ors.rb
Created July 12, 2016 05:01
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)