instanceof Enum.type

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

I know it’s not a Java, but anyway, how I can the check enum type?

enum ETestType {

func check(enumType):
        if enumType is ETestType:
            print("is a my enum what i need!")

Or there is no way check it?

P.S> if it helps, I need that for only one function for ALL my enums stored in Singleton.
actually for calling the name of Enum by Singleton.get_enum_name(enumType)

func get_enum_name(enumType, idx):
    if enumType is EMyEnum:
        return EMyEnum.keys()[idx]

THank you guys!

:bust_in_silhouette: Reply From: rico345100

As far as I know, enum in Godot is just syntactic sugar for dictionary type, so you can’t use it as a type. According to document here: Static typing in GDScript — Godot Engine (3.1) documentation in English

You can’t use Enums as types:

Hope this also will help: What is enum? - Archive - Godot Forum