Sobes.tech
Junior — Senior

Returning a value when using defer with a named result

livecode

Task condition

It is necessary to determine what value will be returned by the function test1, considering the order of execution of the deferred function and the change in the result variable.

func main() {
  fmt.Println(test1())
  test3()
}

func test1() (out int) {
  defer func() {
    out++
  }()
  return
}