DEV Community

Nitin Bansal
Nitin Bansal

Posted on

Let's confuse you all between arrays and slices in golang😎. Also, a small gift...

#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)[:]

🤩Bonus if you are from India🤩: Small appreciation token of ₹100 to whoever first gives proper explanation for each case (transferred on UPI).

Discussion (0)