Attempt to index local 'self' (a nil value)

前端 未结 3 1196
伪装坚强ぢ
伪装坚强ぢ 2021-01-11 09:25

I have a problem with classes. I got below error: Attempt to index local \'self\' (a nil value) When I call the getter method of below class. Item.lua file:

         


        
3条回答
  •  有刺的猬
    2021-01-11 10:09

    the obj:method is just syntactictal sugar for:

    definition:

    function obj:method(alpha) is equivalent to obj.method(self,alpha)

    execution:

    obj:method("somevalue") is equivalent to obj.method(obj,"somevalue") Regards

提交回复
热议问题