Quantcast
Channel: Golang mixed assignment and declaration - Stack Overflow
Viewing all articles
Browse latest Browse all 5

Answer by user for Golang mixed assignment and declaration

$
0
0

In short: as a, b = 2, 3 means "assign both" and a, b := 2, 3 means "declare and assign both", and you need to assign one and declare and assign the other, the solution is to declare the other and assign both:

a := 1{    var b int    a, b = 2, 3}

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>