1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Core: Add Callable.create static method for Variant callables

This commit is contained in:
Danil Alexeev
2024-02-28 12:53:34 +03:00
parent f77bc87211
commit d90c9db27f
6 changed files with 71 additions and 15 deletions

View File

@@ -1,6 +1,13 @@
func test():
var array: Array = [1, 2, 3]
print(array)
var callable: Callable = array.clear
callable.call()
var array_clear: Callable = array.clear
array_clear.call()
print(array)
var dictionary: Dictionary = {1: 2, 3: 4}
print(dictionary)
# `dictionary.clear` is treated as a key.
var dictionary_clear := Callable.create(dictionary, &"clear")
dictionary_clear.call()
print(dictionary)

View File

@@ -1,3 +1,5 @@
GDTEST_OK
[1, 2, 3]
[]
{ 1: 2, 3: 4 }
{ }