var containing the result of the operation, or var.init if the
operation is not supported for the given types.
Notes: Integer division/modulo by zero returns var.init (NULL) instead of silently yielding 0.
var opBinary(string op)(const var rhs) if (op == "+" || op == "-" || op == "*" || op == "/" || op == "%") const @safeBinary arithmetic operators for var.
Supported operators: `+`, `-`, `*`, `/`, `%`
Type promotion rules:
DOUBLE, FLOAT, or REAL, the result is DOUBLE.ULONG and the other is unsigned or fits, result is ULONG.LONG, result is LONG.INT for smaller integer types.the operation returns var.init (NULL).
op | The binary operator (`"+"`, `"-"`, `"*"`, `"/"`, `"%"`). |
rhs | The right-hand side operand. |
var containing the result of the operation, or var.init if the
operation is not supported for the given types.
Notes: Integer division/modulo by zero returns var.init (NULL) instead of silently yielding 0.
var opBinary(string op)(const var rhs) if (op == "~") const @safeString concatenation operator for var.
Concatenates two var values as strings using the `~` operator. If either operand is a string, both operands are converted to their string representation and concatenated.
rhs | The right-hand side operand. |
var containing the concatenated string result.
Returns var.init (NULL) if neither operand is a string.
var a = "Hello";
var b = " World";
assert((a ~ b).as!string == "Hello World");
var num = 42;
assert(("Value: " ~ num).as!string == "Value: 42");