The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

HI everyone.
I am quite a newbie for programming and also Godot

so I just wonder about Godot variable stores the actual object or its pointer reference.

for instance
if i have an object called "SomeObject" and it has a property a = 1, so I assign it to variables item1 and item2

var item_1 = SomeObject
var item_2 = SomeObject

# 1

item_2.a = 100

#??? what will be printed 1 or 100 ? 

thanks in advance for your answers.

in Engine by (28 points)

1 Answer

+2 votes
Best answer

It will print 100. Objects, Arrays and Dictionaries are passed by reference, while primitive types like int, bool, float, Vector2, Vector3, Transform2D and Transform are passed by value.

by (29,360 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.