Execute an eval in a thread : eval « Development « Ruby
- Ruby
- Development
- eval
Execute an eval in a thread
def safe_eval(str)
Thread.start { # Start sandbox thread
$SAFE = 4 # Upgrade safe level
eval(str) # Eval in the sandbox
}.value # Retrieve result
end
Related examples in the same category