float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

someone someone at somewhere.com
Wed Jun 30 04:17:19 UTC 2021


On Wednesday, 30 June 2021 at 03:55:05 UTC, Vladimir Panteleev 
wrote:

> If you want to give any type a "null" value, you could use
[`std.typecons.Nullable`](https://dlang.org/library/std/typecons/nullable.html).

At LEAST for some things with currency types like prices which 
cannot be zero because 0 makes no sense for a price:

Nullable!(T, nullValue) is more storage-efficient than Nullable!T 
because it does not need to store an extra bool.

This could come handly. We'll see.


More information about the Digitalmars-d-learn mailing list