I was reading through the Roblox Documentation, and I found a Lua global called rawequal(). This seems like a basic equality check to me, but I’m curious since it implies it’s efficient. I’m guessing it works like this?
-- Our variables
local var1 = 2
local var2 = 5
-- Check the variables and display the result
print(rawequal(var1, var2)) -- will print a boolean (true or false) from rawequal()
What are the use cases for rawequal, is it a good method to use instead of == or a different comparison function? Is it useful for efficiency?
rawequal() function is used when working with tables with metatables.
When trying to compare 2 tables which have a metatable with __eq function, the == operator will invoke that function, but rawequal() will bypass that function and will compare these tables like any other tables.