You're thinking in terms of compiled languages. Gdscript isn't designed to work like that. This is the most appropriate way to do it:
extends Reference
class_name MyClass
enum {
MY_CLASS_FROM_X,
MY_CLASS_FROM_SUM,
MY_CLASS_FROM_PRODUCT,
}
var x: float = 0
func _init(how:int, val1, val2=null):
if how == MY_CLASS_FROM_SUM:
x = val1 + val2
elif how == MY_CLASS_FROM_PRODUCT:
x = val1 * val2
else:
x = val1
# main.gd
extends Node2D
func _ready():
var m = MyClass.new(MyClass.MY_CLASS_FROM_X, 10)
print(m.x)
m = MyClass.new(MyClass.MY_CLASS_FROM_SUM, 10, 5)
print(m.x)
m = MyClass.new(MyClass.MY_CLASS_FROM_PRODUCT, 10, 5)
print(m.x)
pass
Maybe you should try C# instead.