3 ms·
Just curious but why does singleton classes/singleton methods in Ruby make it "so there's no guarantee that a change made in code and evaluated in the runtime w
by banister 14y ago
Just curious but why does singleton classes/singleton methods in Ruby make it "so there's no guarantee that a change made in code and evaluated in the runtime will have the desired effect" ?
- jballanc 14y agoWell, a trivial example: class Foo def bar puts "Hello from Foo" end end a = Foo.new def a.bar puts "Hello from a special Foo" end Now, even if you change the definition of "bar" in Foo's class definition, "a" will still have it's own version. This might not seem like a big deal, but as you do more metaprogramming with Ruby, more examples like this pop up.