Skip to content

Instantly share code, notes, and snippets.

@dnch
Created January 19, 2012 23:42
Show Gist options
  • Save dnch/1643764 to your computer and use it in GitHub Desktop.
Save dnch/1643764 to your computer and use it in GitHub Desktop.
Ode To The Splat Operator
def test_exclusions(str)
exclusions = ['a', /^I-/]
case str
when *exclusions then
"Excluded"
else
"Accepted"
end
end
test_exclusions("a") # => "Excluded"
test_exclusions("b") # => "Accepted"
test_exclusions("I-34") # => "Excluded"
test_exclusions("x-34") # => "Accepted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment