mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 04:09:05 +00:00
fix: #408
This commit is contained in:
parent
f7fb06e10a
commit
c5848db951
5 changed files with 47 additions and 5 deletions
|
@ -25,6 +25,8 @@ class Nat(Int):
|
|||
return then__(super().__add__(other), Nat)
|
||||
def __mul__(self, other):
|
||||
return then__(super().__mul__(other), Nat)
|
||||
def __pos__(self):
|
||||
return self
|
||||
|
||||
class NatMut(IntMut): # and Nat
|
||||
value: Nat
|
||||
|
@ -90,6 +92,8 @@ class NatMut(IntMut): # and Nat
|
|||
return NatMut(self.value ** other)
|
||||
else:
|
||||
return NatMut(self.value ** other.value)
|
||||
def __pos__(self):
|
||||
return self
|
||||
def try_new(i): # -> Result[Nat]
|
||||
if i >= 0:
|
||||
return NatMut(i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue