Last active
August 29, 2015 13:56
-
-
Save davidcornu/9193438 to your computer and use it in GitHub Desktop.
Get argument names and values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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