Rawset, Rawget and Rawequal

I’ve recently decided it’s finally the time to learn metatables after a couple years of scripting in lua. So I was going through roblox wiki page about metatables Metatables | Documentation - Roblox Creator Hub and saw those three functions, rawset, rawget and rawequal. Since wiki provides barely any information about them, I was wondering if anyone could answer the next three questions; What each of them does?, When are they used? and Are they “necessary” to learn or should I just skip this topic?

Help appreciated,
rokec123

8 Likes

rawset(t, k, v)

Same as t[k] = v but without invoking __newindex, hence raw (I like calling it “natural” since table access is overloadable as shown)

rawget(t, k)

Same as t[k] but without invoking __index (it naturally will return nil if the key don’t exist)

rawequal(a, b)

Same as a == b but without invoking __eq (it will compare by pointer and not use the overloaded version of ==)

97 Likes

Thank you alot, you helped me way more in a single post than wiki did in an entire article :+1:

11 Likes