Skip to content

Instantly share code, notes, and snippets.

@JohnColvin
Created November 11, 2013 22:19
Show Gist options
  • Select an option

  • Save JohnColvin/7421515 to your computer and use it in GitHub Desktop.

Select an option

Save JohnColvin/7421515 to your computer and use it in GitHub Desktop.
monkey patch fizz buzz
class Integer
def divisible_by?(i)
self%i === 0
end
def fizzbuzz
fizz + buzz
end
def fizz
divisible_by?(3) ? 'fizz' : ''
end
def buzz
divisible_by?(5) ? 'buzz' : ''
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment