Skip to content

Instantly share code, notes, and snippets.

@bemurphy
Created July 27, 2011 16: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 bemurphy/1109678 to your computer and use it in GitHub Desktop.
Save bemurphy/1109678 to your computer and use it in GitHub Desktop.
End the NotNot
def fizzy?(string)
string.match(/fizz/)
end
p fizzy?("foobar") # => nil
p fizzy?("fizzbuzz") # => #<MatchData "fizz">
def fizzy?(string)
!!string.match(/fizz/)
end
p fizzy?("foobar") # => false
p fizzy?("fizzbuzz") # => true
def fizzy?(string)
true & string.match(/fizz/)
end
p fizzy?("foobar") # => false
p fizzy?("fizzbuzz") # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment