mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 20:14:45 +00:00
17 lines
438 B
Python
17 lines
438 B
Python
@Inheritable
|
|
Point2D = Class {x = Int; y = Int}
|
|
Point2D.
|
|
new x, y = Self::__new__ {x; y}
|
|
norm ref self = self::x**2 + self::y**2
|
|
|
|
Point3D = Inherit Point2D, Additional: {z = Int}
|
|
Point3D.
|
|
@Override
|
|
new x, y, z = Self::__new__ {x; y; z}
|
|
@Override
|
|
norm ref self = self::x**2 + self::y**2 + self::z**2
|
|
|
|
UnpackPoint2D = Class {x = Int; y = Int}, Impl: Unpack
|
|
|
|
p = UnpackPoint2D.{x = 1; y = 2}
|
|
UnpackPoint2D.{x; y} = p
|