Skip to content

Instantly share code, notes, and snippets.

@nusco
Created August 18, 2010 13:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nusco/534690 to your computer and use it in GitHub Desktop.
Save nusco/534690 to your computer and use it in GitHub Desktop.
Spell: Monkeypatch
# ==================
# Spell: Monkeypatch
# ==================
# Change the features of an existing class.
"abc".reverse # => "cba"
class String
def reverse
"override"
end
end
"abc".reverse # => "override"
# For more information: http://www.pragprog.com/titles/ppmetr/metaprogramming-ruby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment