I
Iñaki Baz Castillo
Hi, I'll explain my problem with an example code:
=2D----------------------
module M
def hello
puts "hello !!!"
B.new
end
=09
class B
def initialize
puts "B instance initialized !!!"
bye() <--- ERROR !!!!
end
end
end
class A
include M
def bye
puts "bye !!!"
end
end
a =3D A.new
a.hello
=2D----------------------
I want the following behaviour:
irb> a.hello
=3D> "hello !!!"
=3D> "B instance initialized !!!"
=3D> "bye !!!"
But the last bye() gives an error since, of course, "bye" is not defined in=
B=20
class, but in A class.
I know that if it would be:
=2D-----------------
module M
def hello
puts "hello !!!"
bye
end
end
irb> a.hellp
=2D-----------------
This works since "bye()" calls the "bye" method in class A. But this is not=
my=20
case.
How could I call A#bye method from M::B class?
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo
=2D----------------------
module M
def hello
puts "hello !!!"
B.new
end
=09
class B
def initialize
puts "B instance initialized !!!"
bye() <--- ERROR !!!!
end
end
end
class A
include M
def bye
puts "bye !!!"
end
end
a =3D A.new
a.hello
=2D----------------------
I want the following behaviour:
irb> a.hello
=3D> "hello !!!"
=3D> "B instance initialized !!!"
=3D> "bye !!!"
But the last bye() gives an error since, of course, "bye" is not defined in=
B=20
class, but in A class.
I know that if it would be:
=2D-----------------
module M
def hello
puts "hello !!!"
bye
end
end
irb> a.hellp
=2D-----------------
This works since "bye()" calls the "bye" method in class A. But this is not=
my=20
case.
How could I call A#bye method from M::B class?
Thanks a lot.
=2D-=20
I=C3=B1aki Baz Castillo