On 04.12.19 22:40, cstige...@gmail.com wrote:
Hello Golang nuts group.

I've tested golang's slice and got a weird result.

Anyone can explain it?


the variable ss in the for range loop is one and the same variable, with a different value of AA for each iteration. it has only one address. after the for loop is done the variable has the value of the last iteration. you can declare a new variable within the block scope that changes between iterations:

https://play.golang.org/p/UMsez9sX9xO

hope that helps

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d2a1c349-0b4c-9e4f-efbe-e19ed8c4f473%40mb0.org.

Reply via email to