From: gabriele renzi Date: 2004-01-18T09:25:03+09:00 Subject: Re: [HELP] : ruby and the class variables il Sat, 17 Jan 2004 23:10:00 +0100, "smayemba" ha scritto:: >Hi all, > >how can i use the class variables in ruby like in Java : beware, someone may flame you, this are static variables not class ones. >class A >{ > public static foo; >} > >class B >{ > public static bar = A.foo; //A.foo is what i am looking for to do. >} > >Thanks for all ruby has class variables, like this: >> class A >> @@v=10 >> def self.v >> @@v >> end >> end => nil >> A.v => 10 but these are shared with subclasses. You may use instance variables of Class objects like this: >> class A >> class << self >> attr_accessor :v >> end >> end => nil >> A.v=20 => 20 >> A.v => 20