They are described here: https://crystal-lang.org/docs/syntax_and_semantics/literals/array.html
An array of type Literal
Crystal supports an extra literal for arrays and array types. It consists of a type name, followed by a list of elements enclosed in braces ( {} ), and individual elements separated by a comma ( , ).
Array{1, 2, 3}
This literal can be used with any type if it has a constructor without arguments and responds with << .
IO::Memory{1, 2, 3} Set{1, 2, 3}
For a non-generic type like IO::Memory this is equivalent to:
array_like = IO::Memory.new array_like << 1 array_like << 2 array_like << 3
For a type such as Set , the generic type T is inferred from element types in the same way as with an array literal. The above is equivalent to:
array_like = Set(typeof(1, 2, 3)).new array_like << 1 array_like << 2 array_like << 3
Type arguments can be explicitly specified as part of the type name:
Set(Number) {1, 2, 3}
source share