From: "Aaron D. Gifford" Date: 2011-03-26T21:15:42+09:00 Subject: Re: How to get the value of a singleton class? On Sat, Mar 26, 2011 at 4:44 AM, Robert Dober wrote: ... > What bothers us, is this > > x=42 > class << self >  p x # x is *not* seen here > end > > Although you call my code ridiculous, I agree with you, I think that > class << self should be a closure too, and optimized away if not used as such. > For now one cannot do better > Cheers > Robert ... The fact that class and module definitions are NOT closures is preferable in my opinion. irb(main):001:0> foo = "FOO" => "FOO" irb(main):002:0> class MyClass irb(main):003:1> p foo irb(main):004:1> end NameError: undefined local variable or method `foo' for MyClass:Class from (irb):3:in `' from (irb):2 from /usr/local/bin/irb:12:in `
' irb(main):005:0> module MyModule irb(main):006:1> p foo irb(main):007:1> end NameError: undefined local variable or method `foo' for MyModule:Module from (irb):6:in `' from (irb):5 from /usr/local/bin/irb:12:in `
' That just seems right. Aaron out.