[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Passing methods as parameters - the nice way?

Vasyl Smirnov

10/24/2007 3:39:00 PM



On Oct 24, 6:31 pm, "Søren Andersen" <soren.ander...@gmail.com> wrote:
> interface.set_action(:foo)
> interface.call_action => foo called
>
> but, how do I handle it if the method is an instance method on some object?
> program = Program.new
> interface.set_action(:program.foo)?
> No variant of this works for me.


You should pass the target object to the interface as well, and then
do "my_obj.send(an_instance_method_foo)"