var._toBool

private bool _toBool() const @safe

Convert the stored value to bool for logical operations.

Conversion rules:

  • NULL: always false
  • BOOL: the stored boolean value
  • Integers (BYTE, UBYTE, SHORT, USHORT, INT, UINT, LONG, ULONG): true if non-zero
  • Floats (FLOAT, DOUBLE, REAL): true if non-zero
  • Characters (CHAR, WCHAR, DCHAR): true if not '\0'
  • STRING: true if length > 0
  • ARRAY: true if length > 0
  • OBJECT: true if length > 0
  • Datetime types (DATE, TIME, DATETIME, SYSTIME, DURATION): always false

Note

Datetime types return false because there is no universally meaningful

"zero" or "falsy" datetime value (unlike integers where 0 is falsy). Users who need truthiness checks on datetime values should explicitly check !isNull() or compare against a specific sentinel value.