Created
March 27, 2014 11:58
-
-
Save stevenbristol/9806016 to your computer and use it in GitHub Desktop.
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
# called in main | |
pry(main)> local_variables | |
=> [:__, :_, :_dir_, :_file_, :_ex_, :_pry_, :_out_, :_in_, :_erbout] | |
# called in method with no local vars | |
pry(main)> def a; local_variables; end | |
=> nil | |
pry(main)> a | |
=> [] | |
#called in method with 1 local var | |
pry(main)> def a; b = 1; local_variables; end | |
=> nil | |
pry(main)> a | |
=> [:b] | |
# getting the values and the names (which i what is really needed) | |
pry(main)> def a; b = 1; local_variables.each {|name| p "#{name}: #{eval name.to_s}"}; end | |
=> nil | |
pry(main)> a | |
"b: 1" | |
=> [:b] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment