Created
December 15, 2010 08:32
-
-
Save deepak/741773 to your computer and use it in GitHub Desktop.
proc_vars_list
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
| # thanks to banister | |
| # functions are better as they have a different scope - keep the scope under control | |
| str = "hello world" | |
| arr = (1..100).to_a | |
| def foo(str) | |
| Proc.new { str.size }.binding.eval("local_variables + instance_variables") | |
| end | |
| p foo(str) #["str"] | |
| p Proc.new { str.size }.binding.eval("local_variables + instance_variables") #["str", "arr"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment