How do I use null in a struct?
drug
drug2004 at bk.ru
Sat Nov 10 20:13:47 UTC 2018
On 10.11.2018 22:42, Václav Kozák wrote:
> I'm making a Rest API with vibe.d and I have a struct User. Sometimes I
> need to return only a few of the fields. So for example: return User(1,
> null, "John", null, null, ...);
> If I do this, an error occurs: cannot implicitly convert expression null
> of type typeof(null) to ...
> Thanks.
Probably you need Nullable?
https://dlang.org/phobos/std_typecons.html#Nullable
More information about the Digitalmars-d-learn
mailing list