mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
feat: support recursive class definition
This commit is contained in:
parent
418f31e6ed
commit
f3b188e095
13 changed files with 285 additions and 93 deletions
11
examples/list.er
Normal file
11
examples/list.er
Normal file
|
@ -0,0 +1,11 @@
|
|||
IntList = Class NoneType or { .node = Int; .next = IntList }
|
||||
IntList.
|
||||
null = IntList::__new__ None
|
||||
insert self, node = IntList::__new__ { .node; .next = self }
|
||||
fst self =
|
||||
match self::base:
|
||||
{ node; next = _ } => node
|
||||
None => None
|
||||
|
||||
l = IntList.null.insert 1
|
||||
assert l.fst() == 1
|
Loading…
Add table
Add a link
Reference in a new issue