lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am sorry for the lack of attention. The answer was clearly explained in the documentation. The .constructor is called as: "self:super"
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()