D
David Miller
Hello
If I want to add a method to a class, I can use send as shown below. Is
there a similar way to use send to add a method to an object?
class MyClass
end
MyClass.senddefine_method, oof) {'I say poof!'}
x = MyClass.new
x.poof # => "I say poof!"
I can define an object method as follows:
def x.object_poof
'I say object_poof'
end
x.object_poof # => "I say object_poof"
I would like to use send to define object methods but I have not figured
out how.
Thanks
Dave Miller
If I want to add a method to a class, I can use send as shown below. Is
there a similar way to use send to add a method to an object?
class MyClass
end
MyClass.senddefine_method, oof) {'I say poof!'}
x = MyClass.new
x.poof # => "I say poof!"
I can define an object method as follows:
def x.object_poof
'I say object_poof'
end
x.object_poof # => "I say object_poof"
I would like to use send to define object methods but I have not figured
out how.
Thanks
Dave Miller