Rawequal and ==

I’ve always wondered what is the main difference between using rawequal() and ==? The API at https://luau-lang.org/library seems identical to me.

== fires the __eq metamethod if it exists in a metatable; rawequal does not.

It’s necessary if you need to make == comparisons within said metamethods, otherwise you get a stack overflow error.

See also: __index and rawget, and __newindex and rawset.

1 Like

I knew rawget() bypasses __index metamethod. Thanks now I see, so they basically bypasses respective metamethods?

Correct.

It’s how you avoid stack overflow errors resulting from repeatedly calling metamethods unintentionally.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.