nntp2http.com
Posting
Suche
Optionen
Hilfe & Kontakt

super Frage

Von: Michael Maier (xinu@gmx.at) [Profil]
Datum: 14.10.2009 17:38
Message-ID: <hb4rbm$71c$1@newsreader2.utanet.at>
Followup-to: de.comp.lang.ruby
Newsgroup: de.comp.lang.ruby
Hallo.

Ich hab ein Verständnisproblem bei folgendem Code.

module BikeMethods
def info
puts "I'm a Bike."
end
end

class Bike
include BikeMethods
end

class Car
def info
puts "I'm a Car."
end
end

class Vehicle < Car
include BikeMethods

def info
super
end
end

v = Vehicle.new
v.info # returns "I'm a Bike."


Da Vehicle von Car erbt sollte doch super() die Methode info() von Car
aufrufen.
Warum ist das nicht so?

lg
michi



[ Auf dieses Posting antworten ]

Antworten