mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
classref: Sync with current master branch (89cc635)
This commit is contained in:
@@ -68,19 +68,6 @@ 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())
|
||||
|
||||
.. note::
|
||||
|
||||
There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
|
||||
|
||||
Reference in New Issue
Block a user