The best way to check if three variables are identical?

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

Is there a way to check if three (or more) variables are identical like you can do in Python?

if var1 == var2 == var3:
    pass

What would be the most elegant way to do this in GDScript? Would I have to do this?

if var1 == 'string' and var2 == 'string' and var3 == 'string':
    pass

Thanks :slight_smile:

:bust_in_silhouette: Reply From: kidscancode

You can use the transitive property:

if var1 == var2 and var2 == var3:

Thank you!

I am still getting used to GDScript and keep getting stuck at places where it deviates from Python :wink:

MAxSaL | 2018-09-19 15:13