In general, this is not possible because methods are invoked as objects, not variables.
Edit:
If you want to do this with a "function" and not with a method, you can add this to the kernel:
def show(var)
print "#{var} => #{eval(var).pretty_inspect}"
end
and call him through
show "anyvar"
This is a little ugly due to the need to pass the variable name as a string, of course.
source
share