github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/tests/files/a47a.gno (about)

     1  package main
     2  
     3  type S struct {
     4  	i int
     5  }
     6  
     7  func main() {
     8  	sArr := make([]S, 0, 4)
     9  	sArr = append(sArr, S{1}, S{2}, S{3})
    10  
    11  	newArr := append(sArr[:0], sArr[0:]...)
    12  
    13  	// share same underlying array
    14  	println(&sArr[0] == &newArr[0])
    15  
    16  	println(&sArr[1] == &newArr[1])
    17  
    18  	println(&sArr[2] == &newArr[2])
    19  }
    20  
    21  // Output:
    22  // true
    23  // true
    24  // true