Signals with no function parameter

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Billy the Boy

Is there something like:

get_node(...).connect("bla", self, () -> dostuff)

Sometimes only a variable has to be set. Therefore, declaring a whole function isn’t the most attractive way. Since it is possible with C# with a delegate, I wonder if that is available for GDScript.

:bust_in_silhouette: Reply From: sash-rc

Signals are employing mechanism of callbacks “by design”.

If you don’t want to declare “redundant, unattractive whole function” for a multitude of similar cases where you need to assign B to A, just create a one single “assignment” function and pass A and B there, as parameters from signal.

I am aware of that. But that wasnt the question.
Thanks for the “by design” hint. I was able to find the docs; indeed there is no delegaty way of handling this. But thanks anyway :slight_smile:

Billy the Boy | 2020-12-22 13:37