Y
Yaser Sulaiman
[Note: parts of this message were removed to make it a legal post.]
According to Wikipedia, a monkey patch[1] is:
The following statement from the same entry confused me:
I would like to know the exact meaning of monkey patching in Ruby. To be
more specific, I would like to know the answers to the following questions:
1- What does "runtime code" refer to in Ruby?
2- Are "monkey patching" and "open classes" different terms for the same
thing?
3- Is the following considered as monkey patching, or is it something else?
class String
def foo
"bar"
end
end
Regards,
Yaser Sulaiman
P.S. I originally posted this question on stackoverflow[2]. There are some
good
answers over there, but I'm still kinda confused. I hope that someone in the
Ruby
community can clarify this issue for me.
[1]: http://en.wikipedia.org/wiki/Monkey_patch
[2]:
http://stackoverflow.com/questions/394144/what-does-monkey-patching-exactly-mean-in-ruby
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. To be
more specific, I would like to know the answers to the following questions:
1- What does "runtime code" refer to in Ruby?
2- Are "monkey patching" and "open classes" different terms for the same
thing?
3- Is the following considered as monkey patching, or is it something else?
class String
def foo
"bar"
end
end
Regards,
Yaser Sulaiman
P.S. I originally posted this question on stackoverflow[2]. There are some
good
answers over there, but I'm still kinda confused. I hope that someone in the
Ruby
community can clarify this issue for me.
[1]: http://en.wikipedia.org/wiki/Monkey_patch
[2]:
http://stackoverflow.com/questions/394144/what-does-monkey-patching-exactly-mean-in-ruby