Gavin Kistner
10/21/2004 1:46:00 AM
On Oct 20, 2004, at 10:54 AM, Mark Probert wrote:
> class Foo
> def bar(fn)
> eval "self.#{fn}"
> end
> end
>
> class Bar < Foo
> def blah
> puts "blah here"
> end
> end
>
> f = Bar.new
> f.bar("blah")
Does the function need to be a string argument?
f.bar( f.method( :blah ) ) # Pass the actual method reference
or, as others have noted:
class Foo
def bar( meth_name )
self.method(m).call
end
end
...
f.bar( :blah )