method

local_variables

Importance_1
Ruby latest stable (v2_5_5) - 0 notes - Class: Binding
local_variables() public

Returns the names of the binding’s local variables as symbols.

def foo
  a = 1
  2.times do |n|
    binding.local_variables #=> [:a, :n]
  end
end

This method is the short version of the following code:

binding.eval("local_variables")
Show source
Register or log in to add new notes.