2 ms·
I got it. That's a neat example. Do you have to define that deferred function inside the caller, in order to reference the name? Or can you factor out deferred
by 19eightyfour 9y ago
I got it. That's a neat example. Do you have to define that deferred function inside the caller, in order to reference the name? Or can you factor out deferred functions to be used by various callers and pass in the return names for them to modify?
- fpoling 9y agoYou can pass a pointer to the named return values to a function defined outside, like in https://play.golang.org/p/5jBKcUCj8C https://play.golang.org/p/5jBKcUCj8C .