What does the colon (:) do?

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

What does the colon (:slight_smile: do?
Example:
targetBody : CollisionObject2D

:bust_in_silhouette: Reply From: Wakatta

Static typing
In the use case above : is used to declare a variable’s type.
For classes and buitl-in types this exposes their members for use
e.g target._all_members_of_CollisionObject2D

Additionally you can use this with function arguments to force that type as a requirement so any thing that’s not of the type trows an error.
e.g func get_target(targetBody : CollisionObject2D):

Side Note: This actually mandatory in the family of C languages for function and variables and in other use cases is known as Type Casting

What i wrote before was off the top of my head and it took me a while but was able to find the official documentation

Wakatta | 2021-02-10 15:55