alexp
1
Hi!
class BaseClass
def BaseClass.initialization_for_derived_class
@var = do_something
end
end
class DerivedClass < BaseClass
end
I’d like to initialize @var in DerivedClass. Is there some way to run
initialization_for_derived_class when inheriting BaseClass?
alexp
2
Alexander Ponomarchuk wrote:
Hi!
class BaseClass
def BaseClass.initialization_for_derived_class
@var = do_something
end
end
class DerivedClass < BaseClass
end
I’d like to initialize @var in DerivedClass. Is there some way to run
initialization_for_derived_class when inheriting BaseClass?
Yes. ri Class#inherited