Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Slice Type

Like all type expressions, this expression produces a value of the type type.

Also known as a 'slice handle.'

Slice-typed values contain a sequence of values, where each value's type is of the operand's type value.

Assertions

  1. The operand is a value of the type type which is runtime representable.

Representation

Values of any slice type are represented as:

  1. a pointer type on the target platform, which points to the slice's first element, and
  2. a pointer-sized unsigned integer on the target platform, which holds the slice's length.

A slice's elements are contiguously allocated.

Syntax

A slice type is produced by the [] unary prefix applied to an expression; see the expression grammar.