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?
That isn't a function; it's a method of an object. If you want to get an object representing a method, you ask the owning object for it:
For example: