From: Phrogz Date: 2006-10-10T13:20:10+09:00 Subject: Re: "def self.method" vs "class << self; def method" Jeff wrote: > Ken Bloom wrote: > > But you can't do the second one with most > > metaprogrammed methods, for example attr_accessor. > > > > Can you elaborate a little bit more? irb(main):001:0> class C; attr_accessor :foo; end irb(main):002:0> C.foo NoMethodError: undefined method `foo' for C:Class from (irb):2 from :0 irb(main):003:0> C.new.foo => nil irb(main):004:0> class C; class << self; attr_accessor :bar; end; end irb(main):005:0> C.bar => nil