What is () used for?

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

Hi everyone. I want to know what exactly does this symbol do ()

Give me explanation about () please.

:bust_in_silhouette: Reply From: Inces

When i was a total noob it irritated me too, nobody talks about it in any tutorial, it is so confusing :slight_smile:

parentheses after function name are place where You input arguments. For example :

move_toward(vec2(1,2))           draw_square(a,b)

When functions ends with empty parentheses, than it simply intakes no arguments. There are a lot of such functions in Godot, they do usefull thing without using any user input, like:

queue_free()           ready()

But there are also a lot of functions, that don’t require any argument, but You MAY PASS some into parentheses and function will do additional things. You will get used to reading about every method and function in documentation to get the best fo them.

When You create your own custom function You also choose if parentheses are empty or not. For example :

func doubler( number ) :
    return number * 2

This function multiplies any number by 2. Every time it is called it will require caller to input any argument in parenthesis, and it will multiply it by 2. It cannot be called with empty parenthesis, because it will not know what to multiply.