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…
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 tataend
endI 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
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
endAnd 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
endAnd 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
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.
Karl-Heinz
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs