Static Type: How to define the return type of a function as a custom scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By siamak-s

How we can define something like below:

func func_name() -> [A Custom Scene Class]:
    ... do sth ...
:bust_in_silhouette: Reply From: Zylann

Scenes are not classes. Scripts are. I would guess it would be this if your script has a class_name:

func func_name() -> YourClass:

As shown here: Static typing in GDScript — Godot Engine (3.1) documentation in English

Yes! I add ‘class_name’ line on top of my scene’s script and then I could use it as a type.

siamak-s | 2019-08-21 14:08