This is a creation in Article, where the information may have evolved or changed. One, array:
1: Arrays are value types, assignments, and delegates replicate the entire array instead of pointers
2: Array length must be constant for example, var a [3]int
Ii. Initialization of arrays
var a [3]int//DECLARE array variable
var a [3]int = [3]int{1,2,3}//initialized array, and is fixed length
A: = [3]int{1,2,3}//and above are equal
A:=[...] int{1,2,3,4,5,6}//Determine the length of an array by initializing the value
Three, array loop for range
For loop:
var Xun [5]int = [5]int{1, 2, 3, 4, 5}
For xn: = 0; xn < Len (Xun); xn++ {
Fmt. Println (Xun[xn])
}
Range: Loop
For k, V: = Range Xun {
Fmt. Println (k)//Get key value
Fmt. Println (v)//value
}
Four: Array functions
Both the built-in function Len and the CAP return the array ⻓ length (number of elements).
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service