I
Iñaki Baz Castillo
Hi, for some exotic reason I need to define initialize() method in a
module, so a class including such module can invoke super() in its
initialize() method. It seems to work:
--------------------------------------------
module M
def initialize
puts "I'm module M"
end
end
class A
include M
def initialize
puts "I'm class A instance"
super
end
end
A.new
=3D> I'm class A instance
=3D> I'm module M
--------------------------------------------
However I would like to know if there could be an issue by using it. I
do know that constants defined in a module are not accessible from a
class including such module but this is not a problem.
PS: I don't want to inherit A from other class due to the nature of my code=
module, so a class including such module can invoke super() in its
initialize() method. It seems to work:
--------------------------------------------
module M
def initialize
puts "I'm module M"
end
end
class A
include M
def initialize
puts "I'm class A instance"
super
end
end
A.new
=3D> I'm class A instance
=3D> I'm module M
--------------------------------------------
However I would like to know if there could be an issue by using it. I
do know that constants defined in a module are not accessible from a
class including such module but this is not a problem.
PS: I don't want to inherit A from other class due to the nature of my code=