On Thursday, 15 January 2026 at 23:37:59 UTC Mike Schilling wrote:

It's handy behavior, because it let you write

  x , err := method1()
  if err !=nil {
    ...
  }
  y , err := method2()
  if err !=nil {
    ...
  }
instead of having to have multiple error variables.


There are awkward cases though. For example, suppose you had declared x and 
y previously, but not err. Then you are forced to make it asymmetrical:

  x , err := method1()
  ...
  y , err = method2()
  ...

And if you write the similar-looking but more compact version:

  if x , err := method1(); err != nil {
    ...
  }

this has completely different semantics.

-- 
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 visit 
https://groups.google.com/d/msgid/golang-nuts/101bb8c6-7c64-494e-a9eb-6ba56599dc0en%40googlegroups.com.

Reply via email to