Go Arrays: Difference between revisions
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
=Array Literals= | =Array Literals= | ||
<pre> | |||
a := [5]int{1, 2, 3, 4, 5} | |||
</pre> | |||
<pre> | |||
a := [5]int{ | |||
1, | |||
2, | |||
3, | |||
4, | |||
5, | |||
} | |||
</pre> | |||
=Array Operators and Functions= | =Array Operators and Functions= |
Revision as of 23:01, 27 March 2016
Internal
Overview
An array is a numbered sequence of elements, of a single type, and with a fixed length.
Declaration
var a [5]int
A declaration without explicit initialization initializes the array with the type's zero value.
Type inference and initialization declaration:
a := [5]int{1, 2, 3, 4, 5}
Array Literals
a := [5]int{1, 2, 3, 4, 5}
a := [5]int{ 1, 2, 3, 4, 5, }
Array Operators and Functions
Indexing Operator
Indexing operator [] returns the value at that position.