Tag:Empty slice

  • Detailed explanation of the difference between nil slice and empty slice in go

    Time:2022-3-7

    When declaring variables, go language will automatically initialize the memory area corresponding to the variables. Each variable is initialized to the default value of its type. For example, the default value of integer and floating-point variables is 0. The default value of a string variable is an empty string. Boolean variables default to false. The […]

  • Empty slice case in golang

    Time:2021-12-22

    Adding elements to slice with nil value is allowed in golang package main func main() { var s []int s = append(s, 1) } Run successfully~ Supplement: detailed explanation of golang slice 1、 Use of array slices func main() { //1. Create an array slice based on an array var array [10]int = [10]int{1, 2, […]