I want a method to be used within another method and returns the arguments without the need of mentioning the argument names, something like return_arguments
in the following.
def foo a, b, *c
... # part a
p return_arguments
... # part b
end
foo(1, "blah blah", :a, :b)
... # return from part a
# => [1, "blah blah", :a, :b]
... # return from part b
Is this possible? I figured out that binding
, local_variables
, and eval
may be used, but am not sure how to distinguish the arguments from other local variables defined in part a
above. Is there a particular ordering rule for local_variables
? If so, maybe I can use that together with arity
to extract the arguments.