mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-30 04:44:44 +00:00
Add Str <-> Int, Nat convertors
This commit is contained in:
parent
592a77caab
commit
287a65276e
6 changed files with 63 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
from _erg_result import Error
|
||||
from _erg_int import Int
|
||||
|
||||
class Str(str):
|
||||
def __instancecheck__(cls, obj):
|
||||
|
@ -15,6 +16,8 @@ class Str(str):
|
|||
return None
|
||||
def mutate(self):
|
||||
return StrMut(self)
|
||||
def to_int(self):
|
||||
return Int(self) if self.isdigit() else None
|
||||
|
||||
class StrMut(): # Inherits Str
|
||||
value: Str
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue