-
|
I'm not exactly sure what I am surprised that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
In Odin, .? is an optional/union extraction operator with type inference. v.? returns two values: Where:
Example: halve :: proc(n: int) -> Maybe(int) {
if n % 2 != 0 do return nil
return n / 2
}
half, ok := halve(2).?Result If value exists: half = 1
ok = trueIf value is nil: half = 0 // default value of int
ok = falseIf you're on Discord, feel free to ask here: Even GingerBill sometimes replies. |
Beta Was this translation helpful? Give feedback.
In Odin, .? is an optional/union extraction operator with type inference.
v.? returns two values:
(value, ok)Where:
Example:
Result
If value exists:
If value is nil:
If you're on Discord, feel free to ask here:
https://discord.gg/hHxthXp2UD
Even GingerBill sometimes replies.