本文实例讲述了go语言获取数组长度的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
// getting the length of an array is silly, because the length is part of the array's static type
myarray := [3]int{1, 2, 3}
fmt.println(len(myarray)) // prints 3
// getting the length of a slice
myslice := []int{1, 2, 3}
fmt.println(len(myslice)) // prints 3
myarray := [3]int{1, 2, 3}
fmt.println(len(myarray)) // prints 3
// getting the length of a slice
myslice := []int{1, 2, 3}
fmt.println(len(myslice)) // prints 3
希望本文所述对大家的go语言程序设计有所帮助。
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论