Interesting! I wasn't aware of that.

Is there any way to make it work?

It is feasible in your generic example:

def y(str, b)
   eval "/(.)/.match(str)", b
   p $1
end

def x(str)
   y(str, binding)
   p $1
end

x("abc")

# =>
#
# nil
# "a"

But in my case, I need to find the caller's binding :

class String
  alias_method :old_sub!, :sub!
  def sub!(*args, &block)
    eval "old_sub!(*args, &block)", caller_binding
  end
end

But I havn't been able to retrieve it :( Do you have any idea?

Thomas
-- 
Posted via http://www.ruby-forum.com/.