Can we test equality of two array in godot

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alternatif

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.

:bust_in_silhouette: Reply From: Calinou

does array1 == array2 give true?

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