How to resize a slice in Go

1 Answer

0 votes
package main

import "fmt"

func main() {
   nums := []int{1, 2, 3}
   
   nums = append(nums, 4, 5) // Appends elements to the slice
   
   fmt.Println(nums) 
}



/*
run:

[1 2 3 4 5]

*/

 



answered Oct 14 by avibootz
...