Edit

Share via


Concatenation

Concatenations are supported for values of type String and arrays. In both cases, they're expressed via the operator +. For instance, "Hello " + "world!" evaluates to "Hello world!", and [1, 2, 3] + [4, 5, 6] evaluates to [1, 2, 3, 4, 5, 6].

Concatenating two arrays requires that both arrays be of the same type. This requirement differs from constructing an array literal where the compiler determines a common base type for all array items. This difference is because arrays are treated as invariant. The type of the entire expression matches the type of the operands.