var.opOpAssign

void opOpAssign(string op, T)(T rhs) if (op == "~") @safe

Operator `~=` for append or string concatenation.

For Type.STRING, concatenates the string representation of rhs to the current string value. For all other types (including NULL), appends rhs as a new element to an array (converting to array if necessary).

Parameters

rhsThe value to append or concatenate.

Examples

// String concatenation
var s = "Hello";
s ~= " World";
assert(s.as!string == "Hello World");

// Array append
var arr = var([1, 2]);
arr ~= 3;
assert(arr.length == 3);