In Ruby, everything is supposed to be an object. But I have a big problem to get to the function object defined the usual way, like
def f
"foo"
end
Unlike in Python, f is the function result, not the function itself. Therefore, f(), f, ObjectSpace.f are all "foo". Also f.methods returns just string method list.
How do I access the function object itself?
You simply use the
methodmethod. This will return theMethodinstance that matches with that method. Some examples:Hope this helps.