Debian Codegraph @

modules/gdscript/tests/scripts/runtime/features/variadic_functions.gd

raw
1 class A:
2 func f(x: int) -> void:
3 print(x)
4
5 class B extends A:
6 func f(x: int, ...args: Array) -> void:
7 prints(x, args)
8
9 class C extends B:
10 func f(x: int, y: int = 0, ...args: Array) -> void:
11 prints(x, y, args)
12
13 class D extends C:
14 func f(...args: Array) -> void:
15 print(args)
16
17 func test_func(x: int, y: int = 0, ...args: Array) -> void:
18 prints(x, y, args)
19
20 var test_lambda := func (x: int, y: int = 0, ...args: Array) -> void:
21 prints(x, y, args)
22
23 func test():
24 for method in get_method_list():
25 if str(method.name).begins_with("test_"):
26 print(Utils.get_method_signature(method))
27
28 test_func(1)
29 test_func(1, 2)
30 test_func(1, 2, 3)
31 test_func(1, 2, 3, 4)
32 test_func(1, 2, 3, 4, 5)
33
34 test_lambda.call(1)
35 test_lambda.call(1, 2)
36 test_lambda.call(1, 2, 3)
37 test_lambda.call(1, 2, 3, 4)
38 test_lambda.call(1, 2, 3, 4, 5)