30log
30log copied to clipboard
Mixin is not working when :new method is present
Modified example from https://github.com/Yonaba/30log/wiki/Mixins is not working. I just added :new method to example from wiki. It raise an error:
attempt to index local 'aWindow' (a nil value)
I use 30log in Corona SDK. After removing :new method there is no errors:)
-- A simple Geometry mixin
local Geometry = {
getArea = function(self) return self.width * self.height end
}
-- Let us define two unrelated classes
local Window = class ("Window", {width = 480, height = 250})
local Button = class ("Button", {width = 100, height = 50, onClick = false})
function Window:new( name, value )
self.name = name
self.value = value
end
-- Include the "Geometry" mixin in Window and Button classes
Window:with(Geometry)
Button:with(Geometry)
-- Let us define instances from those classes
local aWindow = Window()
local aButton = Button()
-- Instances can use functionalities brought by Geometry mixin.
print(aWindow:getArea()) -- outputs 120000
print(aButton:getArea()) -- outputs 5000
dead?