Better: Don’t use class variables. If there’s a @@foo somewhere in the
ancestry tree of a module or class, this one will be used, instead of
what you set @@foo to in your own class.
A class method works much better:
class Klass @foo = “foo”
def self.foo # note the self receiver. Very important! @foo
end
end
class KlassTwo @foo = Klass.foo # Klass has to be defined before KlassTwo, obviously.
def self.foo @foo
end
end
–
Phillip G.
Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.