var.empty

bool empty() @property const @safe

Check if this value is empty.

A value is considered empty if:

  • It is Type.NULL
  • It is Type.STRING with length 0
  • It is Type.ARRAY with length 0
  • It is Type.OBJECT with no keys

Scalar types (numbers, booleans, characters) are never considered empty.

Returns

true if the value is empty, false otherwise.

Examples

var n;
assert(n.empty);  // NULL is empty
var s = "";
assert(s.empty);  // empty string
var a = var.makeArray();
assert(a.empty);  // empty array
var obj = var.makeObject();
assert(obj.empty);  // empty object
var i = 42;
assert(!i.empty);  // scalars are not empty