Hello all,
I couldn’t find a solid answer online about this.
When using the equality operator (==) on two tables, does it compare their contents or their memory address?
Thank you.
1 Like
From the Lua handbook:
Lua compares tables, userdata, and functions by reference, that is, two such values are considered equal only if they are the very same object. For instance, after the code
a = {}; a.x = 1; a.y = 0 b = {}; b.x = 1; b.y = 0 c = a
you have that
a==c
buta~=b
.
Tables are compared by memory address, content or the way it is stored (Arrays, Dictionaries) play no role in comparison.