Skip to content

Instantly share code, notes, and snippets.

@nikolaydubina
Created June 24, 2023 03:18
Show Gist options
  • Save nikolaydubina/fa814acfe92ec0bb936562ac8b9ddfa9 to your computer and use it in GitHub Desktop.
Save nikolaydubina/fa814acfe92ec0bb936562ac8b9ddfa9 to your computer and use it in GitHub Desktop.
// does go unpack multiple assignment with variable returns?
// no 🙅🏻‍♂️
// https://go.dev/play/p/8wKi-2J7aL7
package main
import "fmt"
func one(v int) int { return v }
func two() (int, int) { return 2, 3 }
func three() (int, int, int) { return 4, 5, 6 }
func main() {
// does not compile
// a, b, c, d, e := two(), three()
// a, b, c, d, e := two(), one(3), one(4), one(5)
// compiles
a, b, c, d, e := one(1), one(2), one(3), one(4), one(5)
fmt.Println(a, b, c, d, e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment