mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
GDScript: Clarify the use of callv() to call variadic functions (#11501)
This commit is contained in:
@@ -1651,13 +1651,20 @@ as a static type of the rest parameter:
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
func log_data(...values):
|
func test_func(...args):
|
||||||
# ...
|
|
||||||
|
|
||||||
func other_func(...args):
|
|
||||||
#log_data(...args) # This won't work.
|
#log_data(...args) # This won't work.
|
||||||
log_data.callv(args) # This will work.
|
log_data.callv(args) # This will work.
|
||||||
|
|
||||||
|
func log_data(...values):
|
||||||
|
# You should use `callv()` if you want to pass `values` as the argument list,
|
||||||
|
# rather than passing the array as the first argument.
|
||||||
|
prints.callv(values)
|
||||||
|
# You can use array concatenation to prepend/append the argument list.
|
||||||
|
write_data.callv(["user://log.txt"] + values)
|
||||||
|
|
||||||
|
func write_data(path, ...values):
|
||||||
|
# ...
|
||||||
|
|
||||||
Abstract functions
|
Abstract functions
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user