mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
28 lines
456 B
Python
28 lines
456 B
Python
@Inheritable
|
|
C = Class {.x = Int}
|
|
C::
|
|
aaa = 1
|
|
C.
|
|
bbb = 1
|
|
id self = self
|
|
f self = None
|
|
|
|
D = Inherit C
|
|
D::
|
|
ccc = 1
|
|
D.
|
|
ddd = 1
|
|
g self =
|
|
_ = self.x
|
|
# _ = self::aaa # outer class privates cannot be accessed
|
|
_ = self.bbb
|
|
_ = self::ccc
|
|
_ = self.ddd
|
|
_ = self.f
|
|
_ = self.g
|
|
_ = do self.g()
|
|
None
|
|
|
|
d = D.new({.x = 1})
|
|
print! d.bbb, d.ddd, d.g()
|
|
assert d.id().ddd == 1
|