mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 04:09:05 +00:00
Fix builtin types methods
This commit is contained in:
parent
c56ef64576
commit
8cdc735486
12 changed files with 180 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
|||
from _erg_result import Error
|
||||
from _erg_int import Int
|
||||
from _erg_control import then__
|
||||
|
||||
class Str(str):
|
||||
def __instancecheck__(cls, obj):
|
||||
|
@ -18,6 +19,14 @@ class Str(str):
|
|||
return StrMut(self)
|
||||
def to_int(self):
|
||||
return Int(self) if self.isdigit() else None
|
||||
def __add__(self, other):
|
||||
return then__(super().__add__(other), Str)
|
||||
def __radd__(self, other):
|
||||
return then__(super().__radd__(other), Str)
|
||||
def __mul__(self, other):
|
||||
return then__(super().__mul__(other), Str)
|
||||
def __mod__(self, other):
|
||||
return then__(super().__mod__(other), Str)
|
||||
|
||||
class StrMut(): # Inherits Str
|
||||
value: Str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue