How to use Super in Inheritance and Classes


Hi guys i have a question. i understand that "super" its used when you want to use the same attributes as the Parent class... but in this code why does it matter to put Super ?

class Message
    @@messages_sent = 0
    def initialize(from, to)
        @from = from
        @to = to
        @@messages_sent += 1

my_message ="Phokgedi", "Pabalelo") #our instance

class Email < Message
    def initialize(from, to)

I would have just wrote:
class Email < Message; end

and this was going to inherit everything from superclass from my understanding without writing a method inside the inheritance. help me understand this concept of inheritance better if i'm wrong?



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.