null == "" is true?

Kagamin spam at here.lot
Tue Jul 19 16:55:39 UTC 2022


On Tuesday, 19 July 2022 at 10:29:40 UTC, Antonio wrote:
> The summary is that a DTO that works like a Map needs to 
> represent the absent key ant this is not the same that the Null 
> value
>
> Example:
> ```d
> struct Null { /*...*/ }
> struct Undefined { /*...*/ }
> struct ContactDto {
>  DtoVal!(Undefined, string) name
>  DtoVal!(Undefined, Null, string) phonenumber,
>  DtoVal!(Undefined, AddressDto) address
> }
> // ...
> ContactDto data = {phonenumber:Null(), 
> address:{city:{code:"BCN"}}};
> updateContact(id, data);
>
> ```

As I understand, in your scenario there's no difference between 
null string and empty string, they both work like empty string, 
and D treats them as empty string. That's what I mean when I said 
that distinction between null and empty is meaningless.


More information about the Digitalmars-d-learn mailing list