Answer the question
In order to leave comments, you need to log in
Why can't I get the number of elements in an array?
I'm an amateur in this matter, I ask you not to throw slippers, but a problem arose
. I created a certain "class" to which I add elements, and when I try to find out the number of elements that are present in the array, I write 0 through "#"
class = {}
function class:new()
local class = {}
class.layer = {}
function class:add(object)
for key, value in pairs(object) do
self.layer[key] = value
end
end
function class:returnCount()
return #self.layer --Вернет 0
end
setmetatable(class, self)
self.__index = self; return class
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question