Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
June 23, 2023
slice2 := [][]int{} for i := range slice { slice := []int{0, 0} slice[0] = i slice[1] = i slice2 = append(slice2, slice) } fmt.Println(slice2)
A slice is a descriptor of an array segment. It consists of a pointer to the array, the length of the segment, and its capacity (the maximum length of the segment).
Here appending a slice(pointer) not the slice’s values. To get the desired result you have to declare a new slice in each iteration and append the new slice to slice2.