HUGO
Menu
GitHub 90605 stars Mastodon

collections.Slice

Returns a slice created from the given values.
Syntax
collections.Slice [VALUE...]
Returns
[]any
Alias
slice

Usage

The collections.Slice function returns a slice created from the given values. The values may be of any data type, and you can mix data types within the same slice. Call the function without arguments to create an empty slice.

Examples

{{ $s := collections.Slice "a" "b" "c" }}
{{ $s }} → [a b c]

Mixing data types:

{{ $s := collections.Slice "a" 1 true (collections.Slice 2 3) }}
{{ $s }} → [a 1 true [2 3]]

Creating an empty slice:

{{ $s := collections.Slice }}
{{ $s }} → []