G
GGarramuno
Is there a way to turn a method into a proc stored in a variable?
Something similar to Perl's \& notation.
Say I have a method written and I want to call it indirectly, thru a
proc object. I basically want to get the "address" of the method (or
have a proc object referring to it)
def myfunc(t)
puts t
end
t = \&myfunc #this line is perl's way of doing it
t.call("hello")
The idea behind calling functions like these indirectly is so as to
have the ability of the proc object to refer to built methods and/or
on the fly written procs.
Ruby seems to have this functionality, but I cannot find the proper
syntax.
Something similar to Perl's \& notation.
Say I have a method written and I want to call it indirectly, thru a
proc object. I basically want to get the "address" of the method (or
have a proc object referring to it)
def myfunc(t)
puts t
end
t = \&myfunc #this line is perl's way of doing it
t.call("hello")
The idea behind calling functions like these indirectly is so as to
have the ability of the proc object to refer to built methods and/or
on the fly written procs.
Ruby seems to have this functionality, but I cannot find the proper
syntax.