null == "" is true?

ag0aep6g anonymous at example.com
Tue Jul 12 20:27:14 UTC 2022


On 12.07.22 22:14, H. S. Teoh wrote:
> Pedantically, no, they're not the same. You can assign null to a
> pointer, but you can't assign [] to a pointer. `null` is a supertype of
> `[]`.
> 
> But probably nobody actually cares about this distinction. :-D

If we're ignoring context, "null" has four characters, while "[]" has 
only two. Clearly, they're not similar at all.

The context was arrays, not pointers. `void f(T[] a = null) {}` has 
exactly the same meaning as `void f(T[] a = []) {}`.


More information about the Digitalmars-d-learn mailing list