optionals

This commit is contained in:
agra
2026-02-22 22:16:30 +02:00
parent d3e574eae5
commit 1cc67f9b5a
17 changed files with 1952 additions and 32 deletions

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1,20 @@
x = 42
y = null
x! = 42
x ?? 0 = 42
y ?? 99 = 99
if-bind x: 42
if-bind y: none
match some: 42
match none: 0
p?.value = 10
q?.value = 0
o1.inner?.val = 99
o2.inner?.val = 0
narrowed a: 10
guard 42: 42
guard null: 0
both: 10 20
guard2: 7
default next: null
comptime: 141

View File

@@ -249,6 +249,9 @@ cast-int-f64: 42.000000
run-const: 25
run-expr: 42
run-chain: 30
ct-opt-coalesce: 141
ct-opt-unwrap: 77
ct-opt-guard: 10
insert-ok
insert-gen: 42
=== 9. Flags ===
@@ -386,4 +389,41 @@ buf reset: 0
1 == (1)
(1) == 1
1 == 1
--- optionals ---
opt x: 42
opt y: null
unwrap: 10
coalesce a: 42
coalesce b: 99
if-bind x: 7
if-bind y: none
match some: 55
match none: 0
wrap pos: 5
wrap neg: null
opt field default: null
opt field set: 42
opt param a: 42
opt param b: 0
opt param 7: 7
generic opt 1: 5
generic opt 2: 7
generic opt 3: null
chain some: 10
chain none: 0
chain print: 20
chain null: null
deep chain 1: 99
deep chain 2: 0
narrow x: 42
narrow y else: null
narrow else x: 42
guard some: 42
guard none: 0
and both: 10 20
and one null
or guard: 7
or guard null: 0
nested narrow: 10 20
guard loop: 3
=== DONE ===