From: Alex Combas Date: 2006-01-26T12:05:44+09:00 Subject: class variable weirdness I was fooling around with class variables tonight, and I know this is pretty silly, but forsome reason this code will work when in its own class, as you can see in class A and class B, but when I put the code together into class C I get an error class_vars.rb:26: undefined method `up=' for C:Class (NoMethodError) Can anyone explain why this is happening? class A @@foo=1 def self.foo=(n) @@foo = n end end #prints "10" puts "%s" % A.foo=10 class B @@foo=1 def self.up @@foo+=1 end end #prints "2" puts "%s" % B.up class C @@foo=1 def self.foo=(n) @@foo = n end def self.up @@foo+=1 end end #should print "2, 10" but it doesn't work for me. puts "%s, %s" % (C.up,C.foo=10) -- Alex Combas http://noodlejunkie.blogspot.com/