@@ -65,8 +65,8 @@ here's an example of how GDScript looks.
6565    var v3 = Vector3(1, 2, 3) 
6666
6767
68-     # Functions . 
69-     func some_function(param1, param2, param3): 
68+     # Function, with a default value for the last parameter . 
69+     func some_function(param1, param2, param3 = 123 ): 
7070        const local_const = 5 
7171
7272        if param1 < local_const: 
@@ -1411,6 +1411,20 @@ function's first argument, unlike Python).
14111411
14121412A function can ``return `` at any point. The default return value is ``null ``.
14131413
1414+ By default, all function parameters are required. You can make one or more
1415+ parameters at the end optional by assigning a default value to them:
1416+ 
1417+ ::
1418+ 
1419+     # Since the last two parameters are optional, all these calls are valid: 
1420+     # - my_function(1) 
1421+     # - my_function(1, 20) 
1422+     # - my_function(1, 20, 100) 
1423+     func my_function(a_required, b_optional = 10, c_optional = 42): 
1424+         print(a_required) 
1425+         print(b_optional) 
1426+         print(c_optional) 
1427+ 
14141428If a function contains only one line of code, it can be written on one line:
14151429
14161430::
@@ -2229,7 +2243,7 @@ abstract class:
22292243    an abstract class to a node. If you attempt to do so, the engine will print
22302244    an error when running the scene:
22312245
2232-     :: 
2246+     ..  code-block ::  none 
22332247
22342248        Cannot set object script. Script '<path to script>' should not be abstract. 
22352249
@@ -2382,10 +2396,10 @@ There are a few things to keep in mind here:
23822396
23832397   ::
23842398
2385-    # idle.gd
2399+         # idle.gd 
23862400
2387-    func _init():
2388-        super(5)
2401+         func _init(): 
2402+             super(5) 
23892403
23902404Static constructor
23912405~~~~~~~~~~~~~~~~~~ 
0 commit comments