View Single Post
10-13-17, 12:58 PM   #1
Alizia
A Murloc Raider
Join Date: Oct 2017
Posts: 8
OOP and metatables - pairs problem

Hello everyone,

I want to use some classes for my addon, but I have a problem with pairs() in methods. A exemple :

Code:
ClassTest = {}
ClassTest.__index = ClassTest

function ClassTest:New()
   local self = {}
   setmetatable(self, ClassTest)
   
   self.tab = {}
   return self
end

function ClassTest:CheckTab()
   for i=1, stat in pairs(self.tab) do
      -- Do something
   end
end
There is a error on pairs() function. I find this topic that seem a similar problem, but metatables are new for me and I don't understand the (potential) solution.
  Reply With Quote