var.extend

void extend(T)(T rhs) @safe

Extend this array with elements from another array (flat concatenation).

Unlike append, which adds the argument as a single element (potentially creating nested arrays), extend iterates over the elements of the argument and adds each one individually, resulting in a flat array.

If the argument is not an array, it behaves like append (adds as single element). Converts Type.NULL to an empty array on first use.

Parameters

rhsThe value to extend with. If it's an array, each element is added individually. Otherwise, it's added as a single element.

Examples

var arr = var([1, 2]);
arr.extend([3, 4]);
assert(arr.length == 4);
assert(arr[2].as!int == 3);
assert(arr[3].as!int == 4);

// Compare with append (creates nested array):
var arr2 = var([1, 2]);
arr2.append([3, 4]);
assert(arr2.length == 3);  // [1, 2, [3, 4]]