T
Thijs De vries
Hey guys,
I was wondering how to set class variables using a class method, for
example:
class Foo
@@this_works = 'hello'
@@this_does_not = self.goodbye
def self.goodbye
return 'goodbye'
end
end
Is there an equivalent to initialize but for loading class variables? I
was able to get something above to work by adding a method:
def self.this_does_not=()
@@this_does_not = var
end
and than calling:
Foo.this_does_not = Foo.goodbye
but this would force me to use public methods and in terms of
organization, I like to define class methods at the top.
I was wondering how to set class variables using a class method, for
example:
class Foo
@@this_works = 'hello'
@@this_does_not = self.goodbye
def self.goodbye
return 'goodbye'
end
end
Is there an equivalent to initialize but for loading class variables? I
was able to get something above to work by adding a method:
def self.this_does_not=()
@@this_does_not = var
end
and than calling:
Foo.this_does_not = Foo.goodbye
but this would force me to use public methods and in terms of
organization, I like to define class methods at the top.