"Maybe-fy" operator

This commit is contained in:
Ginger Bill committed 2016-10-08 10:01:29 +01:00
1 parent c5d20d2eef
commit a5c6340316
5 files changed
+46 -27

No files matched your search

+1 -11
View File
@@ -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
}