method
eval
v1_9_2_180 -
Show latest stable
- Class:
Kernel
eval(p1, p2 = v2, p3 = v3, p4 = v4)public
Evaluates the Ruby expression(s) in string. If binding is given, which must be a Binding object, the evaluation is performed in its context. If the optional filename and lineno parameters are present, they will be used when reporting syntax errors.
def getBinding(str) return binding end str = "hello" eval "str + ' Fred'" #=> "hello Fred" eval "str + ' Fred'", getBinding("bye") #=> "bye Fred"