On 7/12/22 12:27 PM, Antonio wrote:
It works

```d
void main()
{
    assert(null=="");
}
```

why?

A string is not exactly a reference type. It's a length and a pointer. This can be confusing to newcomers, especially ones that come from languages that treat arrays and strings as object references.

`null` as an array with `0` length and `null` pointer.

`""` is an array with `0` length and a pointer to a zero character (not `null`).

The algorithm to compare *any* arrays is first verify the lengths are the same. Then for each element in the array, compare them. Since there are 0 elements in both the empty string and the null string, they are equal.

-Steve

Reply via email to