lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes, I understand this. I can't index anything but a table.

Actually, you can. You can index anything any value that has a
metatable set up to allow it, which is largely for tables, sure, but
also full userdata, and base types can have a shared metatable too.
For instance, you *can* index strings (just not assign values to an
index):

a = "a string"
b = a.lower

...will assign the string.lower() function to b. The string type has a
metatable that looks up the "string" library table when you index a
string. So it's not a safe assumption that if something is indexed,
it's a table.