Problem with printing slice address and value in Go language

In Go language, elements in an array or slice can be accessed by using the [] operator. When you use the [] operator to access a single element of an array or slice, the operator returns the value of that element.
And when you use the [] operatorWhen accessing a range of an array or slice, this operator returns a new slice, this slice contains a subset of elements from the original slice. Thus, b[1] accesses the value of the element at index 1 in the slice, and b[1:2] accesses the new slice from index 1 up to and including index 2.

	b := []int{
    
    1, 2, 3, 4}
	println(b[1])
	println(b[1:2])

Output:

2
[1/3]0xc00004dc38

Guess you like

Origin blog.csdn.net/qq_46110497/article/details/129580769