Corona class doesn't work

I am trying to create a dog class on corona and it shows me an error

dog.lua

-- dog.lua -- -- Example "dog" class for Corona SDK tutorial. -- ------------------------------------------------- local dog = {} local dog\_mt = { \_\_index = dog } -- metatable ------------------------------------------------- -- PRIVATE FUNCTIONS ------------------------------------------------- local function getDogYears( realYears ) -- local; only visible in this module return realYears \* 7 end ------------------------------------------------- -- PUBLIC FUNCTIONS ------------------------------------------------- function dog.new( name, ageInYears ) -- constructor local newDog = { name = name or "Unnamed", age = ageInYears or 2 } return setmetatable( newDog, dog\_mt ) end ------------------------------------------------- function dog:rollOver() print(self.name.."rollOver") end ------------------------------------------------- function dog:sit() print( self.name .. " sits down in place." ) end ------------------------------------------------- function dog:bark() print( self.name .. " says \"woof!\"" ) end ------------------------------------------------- function dog:printAge() print( self.name .. " is " .. getDogYears( self.age ) .. " in dog years." ) end ------------------------------------------------- return dog

main.lua

local dog = require( "dog" ) local dog1 = dog.new( "Yai-Ya", 4 ) dog1.rollOver()

it says there is a problem on dog.lua line 36 what is the problem?

u forgot to say what the error IS (guess:  index self)

class seems ok, so (guess) call the method with a colon not period

The problem is with the self, if i make the method to just print let say “aa” it will work fine

@orizvida, I recommend you to read this article as there are a big difference when using a dot or colon in Lua in respect with “self”.

http://www.lua.org/pil/16.html

dog1:rollOver()

u forgot to say what the error IS (guess:  index self)

class seems ok, so (guess) call the method with a colon not period

The problem is with the self, if i make the method to just print let say “aa” it will work fine

@orizvida, I recommend you to read this article as there are a big difference when using a dot or colon in Lua in respect with “self”.

http://www.lua.org/pil/16.html

dog1:rollOver()