Skip to content

Instantly share code, notes, and snippets.

@davidcornu
Last active August 29, 2015 13:56
Show Gist options
  • Save davidcornu/9193438 to your computer and use it in GitHub Desktop.
Save davidcornu/9193438 to your computer and use it in GitHub Desktop.
Get argument names and values
def foo(a,b,c)
method(__method__).parameters.each do |(req, name)|
next unless binding.local_variable_defined?(name)
puts "#{name}: #{binding.local_variable_get(name)}"
end
end
foo('one', 2, :three)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment