M
Marc-antoine Kruzik
Hello, I'm looking for informations about "super".
I have 3 classes : grandfather, father, and son.
And they all have a method named "say_hello".
s = Son.new
s.say_hello
Grand Father : Hello
Father : Hello
Son : Hello
But now, I would that Son didn't call Father, but directly Grand_father.
s.say_hello
Grand Father : Hello
Son : Hello
How could I do that ?
I have 3 classes : grandfather, father, and son.
And they all have a method named "say_hello".
Code:
class Grand_father
def say_hello
puts "Grand Father : Hello"
end
end
class Father < Grand_father
def say_hello
super
puts "Father : Hello"
end
end
class Son < Father
def say_hello
super
puts "Son : Hello"
end
end
s = Son.new
s.say_hello
Grand Father : Hello
Father : Hello
Son : Hello
But now, I would that Son didn't call Father, but directly Grand_father.
s.say_hello
Grand Father : Hello
Son : Hello
How could I do that ?