I want to get the “length” of a dictionary via the unary length operator #. I made myself this:
local t = {
a = 'b',
one = 2,
yes = "no",
True = false
};
setmetatable(t, {__len = function(t)
local len = 0;
for k, v in pairs(t) do
len = len + 1;
end
return len;
end};
print(#t);