And this: package main
import "fmt" func main() { var i int var x = []int{3, 5, 7} //var y = make([]int, 3) for i, x[i] = range x { } fmt.Println("x =", x) // x = [5 7 7] } On Wednesday, December 6, 2017 at 9:26:33 AM UTC-5, T L wrote: > > > package main > > import "fmt" > > func main() { > var i int > var x = []int{3, 5, 7} > var y = make([]int, 3) > for i, y[i] = range x { > fmt.Println(i, ":", y, ", y[", i, "] =", y[i]) > } > fmt.Println("y =", y) > } > > // output: > 0 : [3 0 0] , y[ 0 ] = 3 > 1 : [5 0 0] , y[ 1 ] = 0 > 2 : [5 7 0] , y[ 2 ] = 0 > y = [5 7 0] > -- 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. For more options, visit https://groups.google.com/d/optout.