mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
12 lines
269 B
Python
12 lines
269 B
Python
from _erg_result import Error
|
|
|
|
class Nat(int):
|
|
def try_new(i: int): # -> Result[Nat]
|
|
if i >= 0:
|
|
return Nat(i)
|
|
else:
|
|
return Error("Nat can't be negative")
|
|
|
|
def times(self, f):
|
|
for _ in range(self):
|
|
f()
|