Skip to content
instance method

Binding#local_variable_get

(::interned varname) -> untyped
binding.local_variable_get(symbol) → obj

Returns the value of the local variable symbol.

Example
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:

Example
binding.eval("#{symbol}")

Ruby version changes

  1. 4.0