Skip to content

Commit ed5bc5e

Browse files
committed
GDScript: Clarify the use of callv() to call variadic functions
1 parent 1d24b20 commit ed5bc5e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

tutorials/scripting/gdscript/gdscript_basics.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,13 +1651,20 @@ as a static type of the rest parameter:
16511651

16521652
::
16531653

1654-
func log_data(...values):
1655-
# ...
1656-
1657-
func other_func(...args):
1654+
func test_func(...args):
16581655
#log_data(...args) # This won't work.
16591656
log_data.callv(args) # This will work.
16601657

1658+
func log_data(...values):
1659+
# You should use `callv()` if you want to pass `values` as the argument list,
1660+
# rather than passing the array as the first argument.
1661+
prints.callv(values)
1662+
# You can use array concatenation to prepend/append the argument list.
1663+
write_data.callv(["user://log.txt"] + values)
1664+
1665+
func write_data(path, ...values):
1666+
# ...
1667+
16611668
Abstract functions
16621669
~~~~~~~~~~~~~~~~~~
16631670

0 commit comments

Comments
 (0)