mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-21 05:45:19 +00:00
"Maybe-fy" operator
This commit is contained in:
@@ -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