mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Add extra example to or_return_operator
This commit is contained in:
@@ -2055,6 +2055,9 @@ or_return_operator :: proc() {
|
|||||||
caller_2 :: proc() -> (int, Error) {
|
caller_2 :: proc() -> (int, Error) {
|
||||||
return 123, .None;
|
return 123, .None;
|
||||||
}
|
}
|
||||||
|
caller_3 :: proc() -> (int, int, Error) {
|
||||||
|
return 123, 345, .None;
|
||||||
|
}
|
||||||
|
|
||||||
foo_1 :: proc() -> Error {
|
foo_1 :: proc() -> Error {
|
||||||
// This can be a common idiom in many code bases
|
// This can be a common idiom in many code bases
|
||||||
@@ -2074,7 +2077,10 @@ or_return_operator :: proc() {
|
|||||||
return err1;
|
return err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = n0, n1;
|
// Multiple return values still work with 'or_return' as it only
|
||||||
|
// pops off the end value in the multi-valued expression
|
||||||
|
n0, n1 = caller_3() or_return;
|
||||||
|
|
||||||
return .None;
|
return .None;
|
||||||
}
|
}
|
||||||
foo_2 :: proc() -> (n: int, err: Error) {
|
foo_2 :: proc() -> (n: int, err: Error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user