|Topic was automatically imported from the old Question2Answer platform.
Hello and good day to you,
so I was wondering why should I ever use the
= sign instead of the
:= sign when creating a variable, and my though process for that was :
- First I know that
:=sets the type of the variable when assigning the value, meanwhile
=only assign the value to the variable
- I am currently learning C in university(computer science degree) and I learnt C# in my off-time, so logically speaking I know that an
int32takes less memory than an
int64, and a
floattakes less memory than a
- so I though that if I do not assign a type to my
varin GDscript, does that mean the engine will allocate enough memory for any and all data types?
and so I came to the conclusion that I should always use
:= instead of
= since I am telling the engine that I’ll be using a single type for the variable, thus reserving just the required amount of memory for it, and in turn affecting the performance for the better. But I know that I am a beginner in GDscript so I came here to ask you fellow friends/seniors to help me and tell me why should I use the
:= looks better than
= performance-wise since it assigns a single type to the variable and reduce error-chance, so why should
= be ever used when declaring a variable and what are some of it’s pros?