You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
ldurniat
changed the title
Mixin is not working when :new is present
Mixin is not working when :new method is present
Nov 2, 2017
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:)The text was updated successfully, but these errors were encountered: