Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 

WoWInterface » Developer Discussions » Lua/XML Help » OOP and metatables - pairs problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off