Actions
Bug #9926
closedclass_eval : string and block
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Backport:
Description
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)
Updated by shugo (Shugo Maeda) almost 10 years ago
- 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.
Actions
Like0
Like0