[HELP] : ruby and the class variables

Hi all,

how can i use the class variables in ruby like in Java :

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

Sébastien
DESS Informatique des Systèmes Autonomes
Université Paris 8, France

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

···

il Sat, 17 Jan 2004 23:10:00 +0100, “smayemba” aidez.moi@free.fr ha scritto::