mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-03 18:29:00 +00:00
feat: support symbolized operators
This commit is contained in:
parent
64874f4169
commit
21cb0bb4c1
5 changed files with 187 additions and 147 deletions
|
@ -4,14 +4,15 @@ Point.
|
|||
norm self = self::x**2 + self::y**2
|
||||
Point|<: Add(Point)|.
|
||||
Output = Point
|
||||
__add__ self, other: Point =
|
||||
# This is same as `__add__ self, other: Point = ...`
|
||||
`_+_` self, other: Point =
|
||||
Point.new(self::x + other::x, self::y + other::y)
|
||||
Point|<: Mul(Point)|.
|
||||
Output = Int
|
||||
__mul__ self, other: Point =
|
||||
`*` self, other: Point =
|
||||
self::x * other::x + self::y * other::y
|
||||
Point|<: Eq|.
|
||||
__eq__ self, other: Point =
|
||||
`==` self, other: Point =
|
||||
self::x == other::x and self::y == other::y
|
||||
|
||||
p = Point.new 1, 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue