+1 vote

Hello,
My question is quite simple since I run into a few problems with it
Let's say I have two different arrays (with different references let's call them array1 and array2)
and the content of those arrays is the same( but they don't have the same reference).

does array1 == array2 give true?

I run into an example where it did work and others where it did not. and was wondering if Godot was actually doing a comparison with each value of the array or not.

Right now the temporary solution I found was to use str(array1)==str(array2) for my own example but I found that not really beautiful.

Godot version 3.2.3
in Engine by (24 points)

1 Answer

+1 vote

does array1 == array2 give true?

No, as arrays are compared by reference. You can use array1.hash() == array2.hash() instead.

by (11,917 points)
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 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 webmaster@godotengine.org with your username.