From: Ara.T.Howard@... Date: 2005-04-30T09:54:28+09:00 Subject: Re: advice requested / attributes.rb On Sat, 30 Apr 2005, Dave Burt wrote: > I don't see that it's clear that these are not @@ variables - wouldn't that > be the obvious implementation for that behaviour, and for something called > "class attributes"? if it WERE simply an @@var you'd have class A class_attribute 'x' x 42 end class B < A x 42.0 end p A::x #=> 42.0 but instead you get p A::x #=> 42 p B::x #=> 42.0 if it were simply a class @var you'd have class A class_attribute 'x' x 42 end class B < A end p B::x #=> nil but instead you get p B::x #=> 42 and then if you class C < B; end B::x = 42.0 you'll have p A::x #=> 42 p B::x #=> 42.0 p C::x #=> 42.0 make sense? you __inherit__ the 'x'. with @vars every class has one and there is no sharing. with @@vars there is ONE and ONLY ONE - all classes in a hierarchy share it. this works using follow logic: - if you set the var you have it - else look up ancestry chain for it cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | renunciation is not getting rid of the things of this world, but accepting | that they pass away. --aitken roshi ===============================================================================