From: "David A. Black" Date: 2008-12-28T20:18:30+09:00 Subject: Re: What does 'Monkey Patching' exactly Mean in Ruby? Hi -- On Sun, 28 Dec 2008, marc wrote: > David A. Black said... >> Hi -- >> >> On Sun, 28 Dec 2008, Yaser Sulaiman wrote: >> >>> According to Wikipedia, a monkey patch[1] is: >>> >>>> a way to extend or modify the runtime code of dynamic languages [...] >>>> without altering the original source code. >>> >>> The following statement from the same entry confused me: >>> >>>> In Ruby, the term monkey patch was misunderstood to mean any dynamic >>>> modification to a class and is often used as a synonym for dynamically >>>> modifying any class at runtime. >>> >>> I would like to know the exact meaning of monkey patching in Ruby. >> >> There's no exact meaning. Some people use it to mean re-opening core >> classes; some people use it to mean re-opening core classes in an >> incompetent, unsafe manner; some people use it as a way of indicating >> that any time you re-open a core class, you shouldn't (which is a >> well-intentioned but reductive position); some people use it to mean >> re-opening non-core classes; and so on. > > My brain is fuddled today recovering from flu, but what do you mean by > "reopening"? Like this: class Array def my_new_method end end where I'm reopening the core Array class and adding and/or overriding methods in it. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)