local numbers = {1, 2, 3}
-- # gives the number of items
local length = #numbers
-- length = 3
-- Count by condition
local count_odd = 0
for _, number in ipairs(numbers) do
if number % 2 == 1 then
count_odd = count_odd + 1
end
end
-- count_odd = 2
-- A table is true even when it is empty:
-- compare the length with 0
local is_empty = length == 0
-- is_empty = false
print("length = " .. length)
print("count_odd = " .. count_odd)
print("is_empty = " .. tostring(is_empty))