3 ms·
This is what enables the idiom "foo, err := DoSomething()" where err is declared previously. Without the mixed declaration/redeclaration you'd have to either d
by bkeroack 11y ago
This is what enables the idiom "foo, err := DoSomething()" where err is declared previously.
Without the mixed declaration/redeclaration you'd have to either declare a different error variable every time in the block, or explicitly declare your result variable:
foo1, err1 := DoSomething()
foo2, err2 := DoSomething2()
// or
var Foo foo
var err error
foo, err = DoSomething()
foo, err = DoSomething2()