Skip to content
instance method

Binding#eval

(::string src, ?::string filename, ?::int lineno) -> untyped
binding.eval(string [, filename [,lineno]]) → obj

Evaluates the Ruby expression(s) in string, in the binding’s context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors.

Example
def get_binding(param)
  binding
end
b = get_binding("hello")
b.eval("param")   #=> "hello"

Ruby version changes

  1. 3.0