Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check if a table is empty?

Asked by
danglt 185
5 years ago
function empty()
    print("table empty")
end
-- Place i need help with --

3 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Using #Table will give you the length of it.


table = {182} function is_empty(x) if #table<=0 then return true end end

`

Ad
Log in to vote
0
Answered by
metryy 306 Moderation Voter
5 years ago
if #table < 1 then
    print("Table is empty.")
end

Hope that helped^

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You can do a few things.

local t = {}

if #t < 1 then
 --do code
end

if not t[1] then
 --do code
end

for i,v in pairs(t) do
  if not v then
    --do code
    end
end

0
loooooool raid6n 2196 — 3y

Answer this question