erg/tests/should_ok/var_args.er
2024-04-24 15:24:05 +09:00

16 lines
283 B
Python

p! *x: Int = print! x
p! 1, 2, 3
first *x = x[0]
assert first(1, 2, 3) == 1
sum_ start: Nat, *args: Int =
sum(args, start:=start)
assert sum_(0, 1, 2, 3) == 6
f = (*_: Int) -> None
f(1, 2, 3)
_: Int -> NoneType = f
_: (Int, Int) -> NoneType = f
_: (Int, Nat) -> NoneType = f