From: Mark Volkmann Date: 2006-04-11T03:13:32+09:00 Subject: Re: Quick syntax question On 4/10/06, Austin Ziegler wrote: > On 4/10/06, Gregory Seidman wrote: > > Consider the following three class definitions: > > > > class Foo > > def self.bar > > @@bar > > end > > def self.bar=(val) > > @@bar = val > > end > > end > > > > class Foo > > class << self > > def bar > > @@bar > > end > > def bar=(val) > > @@bar = val > > end > > end > > end > > > > class Foo > > class << self > > attr_accessor :bar > > end > > end > > > > Am I correct in believing that they are equivalent? If not, how do they > > differ? > > They are not equivalent. The first two are the same, That's good to know. I can't see any reason to prefer the second over the first. It's a lot more noisy. > but the third > will be accessing @bar, not @@bar. (Try it in IRB and you'll see.) -- R. Mark Volkmann Object Computing, Inc.