Xavier Noria
11/17/2007 5:21:00 AM
On Nov 16, 2007, at 11:00 PM, Rick DeNatale wrote:
> It only affects the execution context by binding self to the instance,
> NOT the lexical context.
This is related to another thread about constant name resolution
(subject "constant name resolution and module_eval").
Why then *_eval (BLOCK|STRING) behave different?
C = "Object"
class String
C = "String"
end
a = ''
a.instance_eval do
def c_in_block; C; end
end
a.instance_eval <<EOS
def c_in_string; C; end
EOS
puts a.c_in_block # -> Object
puts a.c_in_string # -> String
Looks like there's a "current" module for constant name resolution,
and another "current" module for method definition etc.
-- fxn