This week I got into a conversation regarding monkey-patching. For those
unfamiliar; a monkey-patch
is when you reopen a class outside of your project
and overwrite or add functionality to it. To give an example, here is a little
string monkey-patching goodness:
|
By reopening the String
class and adding an excited
method to it we are able
to add functionality to one of core classes that ships with Ruby, not to shabby.
Also note that it works for instances of String
that were created before the
monkey-patch took place.