Created
June 24, 2023 03:18
-
-
Save nikolaydubina/fa814acfe92ec0bb936562ac8b9ddfa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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