var.opUnary

var opUnary(string op)() if (op == "-" || op == "!") const @safe

Unary operators for var.

Supported operators:

  • `-` (negation): Returns the arithmetic negation of numeric values.
  • `!` (logical not): Returns true if the value is "falsy", false otherwise.

Falsy values for `!`:

  • NULL
  • false (BOOL)
  • 0 (any integer type)
  • 0.0 (any floating type, but not -0.0)
  • Empty string
  • Empty array
  • Empty object

Parameters

opThe unary operator (`"-"` or `"!"`).

Returns

For `-`: A new var with the negated value, or var.init for non-numeric types.

For `!`: A var containing a bool result.