Skip to content

Instantly share code, notes, and snippets.

@deepak
Created December 15, 2010 08:32
Show Gist options
  • Select an option

  • Save deepak/741773 to your computer and use it in GitHub Desktop.

Select an option

Save deepak/741773 to your computer and use it in GitHub Desktop.
proc_vars_list
# 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