![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Krasapan |
What does the colon ( do?
Example:
targetBody : CollisionObject2D
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Krasapan |
What does the colon ( do?
Example:
targetBody : CollisionObject2D
![]() |
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