Is the __len metamethod disabled?

Hello developers,

For a while now, I have had a function called DictionaryGetn to get the amount of keys inside of a dictionary. I have been thinking about switching over to the __len metamethod due to the fact that it will make dictionaries and arrays easy to use. Looking at the documentation, it states that __len metamethod only respects userdata created with newproxy. Is this still the case and will it still work today?

I believe Luau supports the __len metamethod for tables now

local t = setmetatable({}, {__len = function() return 420 end})
print(#t)
> 420
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.