-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88948 from dalexeev/core-add-callable-create
Core: Add `Callable.create` static method for `Variant` callables
- Loading branch information
Showing
6 changed files
with
69 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/runtime/features/builtin_method_as_callable.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
GDTEST_OK | ||
[1, 2, 3] | ||
[] | ||
{ 1: 2, 3: 4 } | ||
{ } |