mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with current master branch (19e7490)
This commit is contained in:
@@ -68,6 +68,19 @@ In GDScript, it's possible to create lambda functions within a method. Lambda fu
|
||||
# Prints "Attack!", when the button_pressed signal is emitted.
|
||||
button_pressed.connect(func(): print("Attack!"))
|
||||
|
||||
\ **Note:** Methods of native types such as :ref:`Signal<class_Signal>`, :ref:`Array<class_Array>`, or :ref:`Dictionary<class_Dictionary>` are not of type **Callable** in order to avoid unnecessary overhead. If you need to pass those methods as **Callable**, use a lambda function as a wrapper.
|
||||
|
||||
::
|
||||
|
||||
func _init():
|
||||
var my_dictionary = { "hello": "world" }
|
||||
|
||||
# This will not work, `clear` is not a callable.
|
||||
create_tween().tween_callback(my_dictionary.clear)
|
||||
|
||||
# This will work, as lambdas are custom callables.
|
||||
create_tween().tween_callback(func(): my_dictionary.clear())
|
||||
|
||||
.. rst-class:: classref-reftable-group
|
||||
|
||||
Constructors
|
||||
@@ -236,13 +249,15 @@ Calls the method represented by this **Callable**. Arguments can be passed and s
|
||||
|
||||
void **call_deferred** **(** ... **)** |vararg| |const|
|
||||
|
||||
Calls the method represented by this **Callable** in deferred mode, i.e. during the idle frame. Arguments can be passed and should match the method's signature.
|
||||
Calls the method represented by this **Callable** in deferred mode, i.e. at the end of the current frame. Arguments can be passed and should match the method's signature.
|
||||
|
||||
::
|
||||
|
||||
func _ready():
|
||||
grab_focus.call_deferred()
|
||||
|
||||
See also :ref:`Object.call_deferred<class_Object_method_call_deferred>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
----
|
||||
@@ -456,3 +471,4 @@ Returns ``true`` if both **Callable**\ s invoke the same custom target.
|
||||
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
|
||||
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
|
||||
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
|
||||
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
|
||||
|
||||
Reference in New Issue
Block a user