[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [LUA]: Cannot use userdata as table index
- From: Choonster TheMage <choonster.2010@...>
- Date: Sat, 11 Jul 2015 02:28:48 +1000
On 11 July 2015 at 02:23, Борис Александров <boriscool007@gmail.com> wrote:
> http://prntscr.com/7r4ecw It seems to me that lua compares table index and
> given value by address, not by _equal metamethod
>
Yes, this is explained in the manual:
The indexing of tables follows the definition of raw equality in the
language. The expressions a[i] and a[j] denote the same table element
if and only if iand j are raw equal (that is, equal without
metamethods).
http://www.lua.org/manual/5.3/manual.html#2.1
Every time you call lua_newuserdata, you're creating a new object
that's not raw equal to any other object.