Closed mationai closed 3 years ago
Not sure that's supported. Looks like the second def shadows the first. You could do something like:
def test[T](a:int, b:T):
print f"{a=}, {b=}"
test(1, [2])
test(1, 2)
Yes, currently we do not support overloaded functions (only overloaded magic methods in class definitions are supported), and the latest definition will shadow the previous ones. We will handle this better once the union types land in develop.
Resolved in #132.
Overloaded functions are not supported (class method, though, are). You can use instead isinstance
that is a compile-time check and that will have the desired effect:
def test(a, b):
if ininstance(b, List[int]): ...
elif isinstance(b, int): ...
error: expected function input type 'int', but got 'list[int]'