DEV Community

Nitin Bansal
Nitin Bansal

Posted on • Edited on

Let's confuse you all between arrays and slices in golang😎

#go

Let's see if you can correctly figure out the types of these (array or slice)

  1. a := [4]int{}
  2. a := []int{}
  3. a := []int{1,2,3}
  4. a := [4]int{}
  5. a := make([]int, 10)
  6. a := new([]int)
  7. a := *new([]int)
  8. a := *new([5]int)
  9. a := new([5]int)[:]

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay