Can someone explain why the following code fails to define the new method
jim() in class Mary? Can you suggest how it can be done? When I run
this, I get an error saying there's no method "jim" in that class.
def fred(object)
name = "jim"
class << object
eval %{
puts "Creating method #{name}() ..."
def #{name}(*arguments)
puts "jim() -- hello there!"
end
}
end
end
class Mary
def initialize
end
end
fred(Mary)
m = Mary.new
m.jim()