ddash.utils.truthy

Truthy values: so not any of false, null, 0, "", none, and NaN.

Members

Aliases

isFalsey
alias isFalsey = from!"std.functional".not!isTruthy

Returns true if value is "falsey", i.e. false, null, 0, "", none, NaN, or empty.

Functions

isTruthy
bool isTruthy(auto ref T value)

Returns true if value is "truthy", i.e. not any of false, null, 0, "", none, NaN, or empty.

Examples

1 assert( isTruthy(true));
2 assert( isTruthy(1));
3 assert(!isTruthy(0));
4 assert( isTruthy((new int(3))));
5 assert(!isTruthy(((int[]).init)));
6 assert( isTruthy([1]));
7 assert(!isTruthy(double.nan));
8 assert(!isTruthy(0.0));
9 assert( isTruthy(1.0));
10 
11 class C {}
12 C c;
13 assert(!isTruthy(c));
14 c = new C;
15 assert( isTruthy(c));
16 
17 struct S {}
18 S s;
19 assert(!__traits(compiles, isTruthy(s)));

Meta