1

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 ?

horseyguy
  • 29,455
  • 20
  • 103
  • 145

2 Answers2

1

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
  • 54,010
  • 13
  • 102
  • 111
0

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

rogerdpack
  • 62,887
  • 36
  • 269
  • 388