can I create a class constructor like in other languages, for example Myclass(arg1, arg2)?

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

Can I create a class constructor the same way Vector(0,0) does without using _init or new()?, for example MyClass(arg1, arg2). I have some classes that do not inherit from Node so I cannot use the method. new(), my question is, can I create class constructors like I would in other object-oriented programming languages, for example MyClass(arg1, arg2)? I have seen how the Vector class uses this method (var my_var = Vector(0,0)) but I don’t know how to implement it in my Script. Does anyone know how to do it?

:bust_in_silhouette: Reply From: Andrew Wilkes

You can use the .new() method. You don’t have to inherit from anything. The new method passes the args to the _init method. Also, maybe you could create a static method to use as a constructor in the way that you wanted?