determining if array element is null

ag0aep6g anonymous at example.com
Sat Jun 2 18:52:41 UTC 2018


On 06/02/2018 08:35 PM, Neia Neutuladh wrote:
> 2. `int[4] a = null` treats the initialization as a copy from an array 
> whose value is null. If you run just that line of code, it will produce 
> an error at runtime: "object.Error@(0): Array lengths don't match for 
> copy: 0 != 4"
> 
> If you want to initialize every member of an array with a value, you 
> write it as:
> 
>      int[4] a;
>      a[] = 5;

`int[4] a = 5;` is fine, too.


More information about the Digitalmars-d-learn mailing list