I already read this post, and I know that you can just use stringified Vector3
s as keys in a dictionary.
I was messing around in Roblox Studio and I wanted to use Vector3
s as keys in a dictionary, and even though I didn’t think it would work, I tested it out and lo and behold, it works?!?
Here is the code I ran to test Vector3
s as dictionary keys:
local thing = {}
thing[Vector3.new(1, 2, 3)] = "yes"
print(thing[Vector3.new(1, 2, 3)])
This prints yes
to the console.
My question is: how does this work, and is it reliable? It is my understanding that Vector3.new
creates a new object, so Vector3
s as dictionary keys isn’t very practical. My guess is that Roblox caches Vector3
s or something…?