Calling coffescript super methods

前端 未结 1 1782
灰色年华
灰色年华 2021-01-03 17:53

I have the following code:

    class Animal
        constructor: (@name) -> 
        say: () -> console.log \"Hello from animal called #{ @name }\"

           


        
1条回答
  •  旧巷少年郎
    2021-01-03 18:51

    I found the answer myself, it should be:

    class Dog extends Animal
    
        say: () ->
            super
            console.log "Hello from dog called #{ @name }"
    

    0 讨论(0)
提交回复
热议问题