|
This code works: class = require('pl.class') class.control() function control:_init(title) self.title = title end class.window(control) function window:_init(title) self:super(title) end function window:show() print(self.title) end window = window('Hello World') window:show() Em 03-01-2013 02:26, Luciano de Souza escreveu:
Hello listers,I have tried some inheritance with Penlight class support. However, I don't know how to call the parent constructor. This code fails, so I ask: what is wrong:class = require('pl.class') class.control() function control:_init(title) self.title = title end class.window(control) function window:_init(title) control:_init(title) end function window:show() print(self.title) end window = window('Hello World') window:show()