Re: Distinguish between a null array and an empty array

2020-05-26 Thread Dukc via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:29:23 UTC, bauss wrote: Dang, that sucks there is no proper way and I would say that's a big flaw of D. Because what I need it for is for some data serialization but if the value is an empty array then it should be present and if it's null then it should not be

Re: Distinguish between a null array and an empty array

2020-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/20 8:12 AM, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that b is an empty array and a is a null array. The issue

Re: Distinguish between a null array and an empty array

2020-05-26 Thread WebFreak001 via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:37:20 UTC, ag0aep6g wrote: On 24.05.20 14:29, bauss wrote: Dang, that sucks there is no proper way and I would say that's a big flaw of D. Because what I need it for is for some data serialization but if the value is an empty array then it should be present and

Re: Distinguish between a null array and an empty array

2020-05-25 Thread Nathan S. via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:12:31 UTC, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that b is an empty array and a is a null

Re: Distinguish between a null array and an empty array

2020-05-24 Thread ag0aep6g via Digitalmars-d-learn
On 24.05.20 14:29, bauss wrote: Dang, that sucks there is no proper way and I would say that's a big flaw of D. Because what I need it for is for some data serialization but if the value is an empty array then it should be present and if it's null then it should not be present. Since null

Re: Distinguish between a null array and an empty array

2020-05-24 Thread ag0aep6g via Digitalmars-d-learn
On 24.05.20 14:12, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that b is an empty array and a is a null array. No way.

Re: Distinguish between a null array and an empty array

2020-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 24, 2020 6:12:31 AM MDT bauss via Digitalmars-d-learn wrote: > Is there a way to do that? > > Since the following are both true: > > int[] a = null; > int[] b = []; > > assert(a is null); > assert(!a.length); > > assert(b is null); > assert(!b.length); > > What I would like is to

Re: Distinguish between a null array and an empty array

2020-05-24 Thread bauss via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:26:42 UTC, ag0aep6g wrote: On 24.05.20 14:12, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that

Re: Distinguish between a null array and an empty array

2020-05-24 Thread bauss via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:12:31 UTC, bauss wrote: Is there a way to do that? Since the following are both true: int[] a = null; int[] b = []; assert(a is null); assert(!a.length); assert(b is null); assert(!b.length); What I would like is to tell that b is an empty array and a is a null