From: Hal Fulton Date: 2012-07-02T22:21:24+09:00 Subject: Question re class instance variable anomaly --047d7b10cec38efa5d04c3d8ac31 Content-Type: text/plain; charset=ISO-8859-1 I was *certain* I had done this sort of thing before -- can someone tell me what's going on? I'm up much too early -- likely a short circuit between my ears. Basically -- Baz acts as I want/expect, and Foo does not. Why?? Thanks, Hal #### class Foo class << self attr_accessor :bar Foo.bar = "hello" end def initialize puts "Foo: #{Foo.bar.inspect}" end end class Baz class << self attr_accessor :bar @bar = "hello" end def initialize puts "Baz: #{Baz.bar.inspect}" end end Foo.new Baz.new --047d7b10cec38efa5d04c3d8ac31 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I was *certain* I had done this sort of thing before -- can someone
tell= me what's going on?

I'm up much too early -- likely a short= circuit between my ears.

Basically -- Baz acts as I want/expect, an= d Foo does not.

Why??

Thanks,
Hal


####

class Foo
=A0 cla= ss << self
=A0=A0=A0 attr_accessor :bar
=A0=A0=A0 Foo.bar =3D &= quot;hello"
=A0 end

=A0 def initialize
=A0=A0=A0 puts &qu= ot;Foo: #{Foo.bar.inspect}"
=A0 end
end

class Baz
=A0 class << self
=A0=A0=A0 att= r_accessor :bar
=A0=A0=A0 @bar =3D "hello"
=A0 end

= =A0 def initialize
=A0=A0=A0 puts "Baz: #{Baz.bar.inspect}"=A0 end
end


Foo.new
Baz.new

--047d7b10cec38efa5d04c3d8ac31--