是否可以在另一个对象的上下文中执行proc?
我知道通常你会做proc.调用(foo),然后块应该定义一个参数.我想知道是否可以让"self"绑定到foo,这样就不需要块参数了.
proc = Proc.new { self.hello }
class Foo
def hello
puts "Hello!"
end
end
foo = Foo.new
# How can proc be executed within the context of foo
# such that it outputs the string "Hello"?
proc.call