Go Slices: Difference between revisions
Jump to navigation
Jump to search
Line 27: | Line 27: | ||
=Slice Operators and Functions= | =Slice Operators and Functions= | ||
==<tt>make()</tt>== | |||
==<tt>append()</tt>== | |||
==<tt>copy()</tt>== | |||
Slice built-in functions <tt>[[Go Built-In Functions Appending to and Copying Slices#append.28.29|append()]]</tt>, <tt>[[Go Built-In Functions Appending to and Copying Slices#copy.28.29|copy()]]</tt>. | Slice built-in functions <tt>[[Go Built-In Functions Appending to and Copying Slices#append.28.29|append()]]</tt>, <tt>[[Go Built-In Functions Appending to and Copying Slices#copy.28.29|copy()]]</tt>. | ||
Revision as of 23:22, 27 March 2016
Internal
Overview
A slice is a reference type that implements a dynamic array. Slices are indexable, and they have a variable length.
TODO Deep difference between slice and array (memory model, etc.)
Declaration
A slice declaration is similar to an array's except the length is not specified. The slice is created with a zero length.
var s []int
Type inferred declaration:
s := make([]int, 5)