Inheritance

Hello,

I have this class :

class A
def toto
puts “tttt”
end
end

class B < A
def tata

end
end

I would like to now how in B.tata I can invoke, I can call the method
toto of A.

Thanks for your reply…

Mickael Veovis wrote:

class B < A
def tata

end
end

I would like to now how in B.tata I can invoke, I can call the method
toto of A.

Thanks for your reply…

If I understand your question correctly:

b = B.new
b.toto

or:

B.new.toto

Best regards,

Jari W.

class B < A
def tata
toto
end
end

Kind regards,
Nicolai

I wrote:

If I understand your question correctly:

Well, I probably misunderstood your it the first time around :wink:

Here’s probably what you were looking for:

class B < A
def tata
toto
end
end

and then:

b = B.new
b.tata

or:

B.new.tata

Mickael Rouvier wrote:

 end

 def tata

 end
end

And I would like in B.tata to call the method toto of A.

def tata
A.instance_method(:toto).bind(self).call
end

HTH,
Sebastian

Sorry, but I make a mistake my class are :

class A
def toto
puts “tttt”
end
end

class B < A
def toto
puts “mmmmm”
end

def tata

end
end

And I would like in B.tata to call the method toto of A.

On 15.02.2008, at 14:17, Sebastian H. wrote:

 puts "mmmmm"

end

def tata

end
end

And I would like in B.tata to call the method toto of A.

class A
def toto
puts “tttt”
end
end

class B < A
alias :totoo :toto
def toto
puts “mmmm”
end
end

b = B.new
b.toto
b.totoo

  • Karl-Heinz

On 15.02.2008, at 14:30, Karl-Heinz Wild wrote:

class B < A

end
def tata
totoo
end

end

b = B.new
b.toto
b.totoo

Ups. :slight_smile:

Karl-Heinz