Skip to content

Instantly share code, notes, and snippets.

@krishnakumar4a4
Created January 26, 2019 01:51
Show Gist options
  • Save krishnakumar4a4/bec8f71901146c798ebfaa3b560a76b7 to your computer and use it in GitHub Desktop.
Save krishnakumar4a4/bec8f71901146c798ebfaa3b560a76b7 to your computer and use it in GitHub Desktop.
Appending elements inside multidimensional arrays in golang using slices
package main
import (
"fmt"
)
func main() {
// Inner dimension cannot be extended if given length
v := [3][3][]int{}
// v[0][0][:] gives the slice of the existing elements
v[0][0] = append(v[0][0][:],1)
v[0][0] = append(v[0][0][:],1)
v[0][1] = append(v[0][1][:],2)
v[0][1] = append(v[0][1][:],3)
fmt.Println("v: ",v)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment