From: David Garamond Date: 2004-06-08T18:53:46+09:00 Subject: Re: accessing class instance variable from instance method Robert Klemme wrote: > - I just don't get why you do @var = "instance" in method > 'class_instance_var'. That's just for testing :-) (to make sure the right '@var' is printed). > - I would not define an instance method that accesses the class's > attribute other than using it as an obfuscating technic. The class has > already an accessor for that. Implementing a method like you did makes > the user think it's an instance var. I seldom do this too. Only when I want to expose a class' attribute to class instance users (and usually only read only too). > - You might want to consider synchronizing access to the class var if > you're in a multithreaded env, because multiple threads might be accessing > the class concurrently. I see. Thanks. > - I prefer "def self.var; @var; end" because that is safe with respect to > class renaming. Yes. Old habits (due to examples in Pickaxe) :-) -- dave