Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | avencherus | |
Old Version | Published before Godot 3 was released. |
I’m not sure what to hunt for on this, but I was wondering how many times a constant will be assigned to memory when you define one inside a class.
Say you did this:
class MyObj:
const DATA = 123
func _ready():
var arr = []
for i in range(100): arr.append(MyObj.new())
Will Godot store 100 copies of this constant in memory?
When I fill an array with objects I can access to the objects using array index so I think array stores pointers and not a copy of the objects.
You can test if it’s works like this even on simple types like integers.
DriNeo | 2017-01-06 17:35