当前位置: 移动技术网 > IT编程>脚本编程>Go语言 > Go语言获取数组长度的方法

Go语言获取数组长度的方法

2017年12月08日  | 移动技术网IT编程  | 我要评论
本文实例讲述了go语言获取数组长度的方法。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下:// getting the length of an array

本文实例讲述了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

希望本文所述对大家的go语言程序设计有所帮助。

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网