From: zdennis Date: 2006-04-11T01:15:46+09:00 Subject: Re: Adding in class attribute with a Module -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 James Britt wrote: > >> I don't like the sprawl of the concept of >> an "attribute" of a class-hierarchy-plus-instances-of-those-classes. I think this is what you are referring to David, and I think it is strange to: zdennis@lima:~$ irb irb(main):001:0> class A irb(main):002:1> @@myvar = 5 irb(main):003:1> class << self ; @myvar = 10 ; end irb(main):004:1> end => 10 irb(main):005:0> A.instance_variables => [] irb(main):006:0> A.class_variables => ["@@myvar"] irb(main):007:0> a = class A ; class << self ; self ; end ; end => # irb(main):008:0> a.instance_variables => ["@myvar"] irb(main):009:0> a.instance_eval "@myvar" => 10 irb(main):010:0> A.module_eval "@@myvar" => 5 irb(main):011:0> It seems like, @@myvar and @myvar should refer to the same reference point. I would expect @@ to signify a class level attribute, which is actually an instance attribute on the class itself. In my head that makes sense. > > > The 'attribute' concept is messy as it is, but this class use seems to > be a natural extension of the 'methods that get/set an object variable > of the same name' idea. > +1 Zach -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEOoW9Myx0fW1d8G0RAtr1AJ4hnjfSYe4cK1Ky42WAiE/xbEAlDQCffyq6 tsuod8moO45731DlZryH/SI= =Wdyv -----END PGP SIGNATURE-----