Can you eval code in the context of a caller in Ruby?

Viewed 8217

Essentially I'm wondering if the following can be done in Ruby.

So for example:

def bar(symbol) 
  # magic code goes here, it outputs "a = 100" 
end

def foo
  a = 100 
  bar(:a) 
end
5 Answers
Related