[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: why doesnt a = 1 work?
- From: "Duncan Cross" <duncan.cross@...>
- Date: Wed, 23 May 2007 12:46:05 +0100
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
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.