Evaluation with variable : eval « Development « Ruby






Evaluation with variable


x = 1
eval "x + 1"  # => 2

 








Related examples in the same category

1.Use eval to run a statement dynamically
2.Execute an eval in a thread
3.eval with variable name
4.Add a new method with eval