Question re class instance variable anomaly

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

Hi,

You’re setting @bar in the wrong context. You make @bar an instance
variable of the eigenclass of Baz rather than of Baz itself:

puts Baz.singleton_class.instance_variables

Of course! Thank you.

Hal