Skip to content
instance method

Binding#local_variables

() -> ::Array[::Symbol]
binding.local_variables → Array

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

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

Example
binding.eval("local_variables")

Ruby version changes

  1. 4.0