method

local_variable_get

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

Returns the value of the local variable symbol.

def foo
  a = 1
  binding.local_variable_get(:a) #=> 1
  binding.local_variable_get(:b) #=> NameError
end

This method is the short version of the following code:

binding.eval("#{symbol}")
Show source
Register or log in to add new notes.