Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Kernel#binding

binding → a_binding

Returns a Binding object, describing the variable and method bindings at the point of call. This object can be used when calling eval to execute the evaluated command in this environment. See also the description of class Binding.

Example
def get_binding(param)
  binding
end
b = get_binding("hello")
eval("param", b)   #=> "hello"
See also #BigDecimal #block_given? #autoload? #callcc also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0