"Maybe-fy" operator

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

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
}