From: shugo@... Date: 2014-06-11T06:21:24+00:00 Subject: [ruby-core:63094] [ruby-trunk - Bug #9926] [Closed] class_eval : string and block Issue #9926 has been updated by Shugo Maeda. Status changed from Open to Closed S��bastien Durand wrote: > I'm not sure, is this a bug or a feature ? > > class Foo; @@bar = 'bar'; end > p Foo.class_eval('@@bar') # => "bar" > p Foo.class_eval { @@bar } => uninitialized class variable @@bar in Object (NameError) It's not a bug, but an expected behavior. The block version of class_eval doesn't affect class variable and constant lookup. ---------------------------------------- Bug #9926: class_eval : string and block https://bugs.ruby-lang.org/issues/9926#change-47161 * Author: S��bastien Durand * Status: Closed * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- I'm not sure, is this a bug or a feature ? class Foo; @@bar = 'bar'; end p Foo.class_eval('@@bar') # => "bar" p Foo.class_eval { @@bar } => uninitialized class variable @@bar in Object (NameError) -- https://bugs.ruby-lang.org/