views:

255

answers:

2

I noticed that class variables @@my_class var are now looked up in the context of the instance_eval'd object in Ruby 1.9.1 whereas this was not the case in Ruby 1.8.6.

What are some other differences in behaviour of instance_eval for Ruby 1.9.1 ?

+1  A: 

I can't list them all, but I know that there are some changes in constant lookup. In 1.8, constant lookup was in the callers scope, while it is in the blocks scope in 1.9.

FOO = "hi"

class Something
  FOO = "bye"

  def self.handle(&block)
    instance_eval(&block)
  end
end

p Something.handle { FOO }
# "hi" on 1.8, "bye" on 1.9
August Lilleaas
A: 

I think it [at least currently] doesn't return self, either.

rogerdpack