Typo: should have said
var foo error
r, bar := os.Open(src) orelse return foo // does this do "if foo != nil {
return foo }" ??
On Sunday, 30 July 2023 at 10:20:12 UTC+1 Brian Candler wrote:
> On Sunday, 30 July 2023 at 09:40:25 UTC+1 DrGo wrote:
>
> orelse must return an error (ie satisfies the error interface); the
> specific type and variable name do not matter.
>
>
> But how does "orelse" perform the check in the first place? Does it look
> for the variable named in the return statement?
>
> var foo error
> r, bar := os.Open(src) orelse return foo // does this do "if foo != nil
> { return bar }" ??
>
> Also, you are explicitly allowing bare return. In that case, does it look
> at the return values in the function definition? If the function returns
> multiple values, how does it know which one?
>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/0410013a-6036-4f06-9a8b-8900b8dd4765n%40googlegroups.com.