"Maybe-fy" operator
This commit is contained in:
1 parent
c5d20d2eef
commit
a5c6340316
5 files changed
+46
-27
No files matched your search
+1
-11
@@ -1,16 +1,6 @@
|
||||
#import "fmt.odin"
|
||||
|
||||
|
||||
main :: proc() {
|
||||
maybe_print :: proc(x: ?int) {
|
||||
if v, ok := x?; ok {
|
||||
fmt.println(v)
|
||||
} else {
|
||||
fmt.println("nowt")
|
||||
}
|
||||
}
|
||||
|
||||
maybe_print(123) // 123
|
||||
maybe_print(nil) // nowt
|
||||
x := ?123
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user