mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
chore: add record examples
This commit is contained in:
parent
5e71bd7fd0
commit
a0ce142f7b
4 changed files with 25 additions and 5 deletions
|
@ -26,3 +26,10 @@ assert Person!.name == Str
|
|||
for! {.x = 1; .y = 2}.as_dict().items(), ((k, v),) =>
|
||||
# k: Str, v: Int
|
||||
print! k, v
|
||||
|
||||
# {=} means the empty record (type), which is the subtype of all records
|
||||
iterate_rec! r: {=} =
|
||||
for! r.as_dict().items(), ((k, v),) =>
|
||||
print! k, v
|
||||
iterate_rec! {a = 1; b = 2}
|
||||
iterate_rec! {a = 1; b = 1.2; c = "a"}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue