Thread overview | |||||
---|---|---|---|---|---|
|
October 10, 2018 typo mapNode[6]* exits; instead of mapNode*[6] exits; but whats it mean ? | ||||
---|---|---|---|---|
| ||||
I'm not sure I understand what mapNode[6]* means! (the second version is what I wanted an array of 6 pointers) oddly when assigning a null to one element of the array it cause an error as it was trying to do an array copy... so what's going on and what does that definition actually mean ? |
October 10, 2018 Re: typo mapNode[6]* exits; instead of mapNode*[6] exits; but whats it mean ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Codifies | On Wednesday, 10 October 2018 at 13:24:42 UTC, Codifies wrote:
> I'm not sure I understand what mapNode[6]* means! (the second version is what I wanted an array of 6 pointers)
>
> oddly when assigning a null to one element of the array it cause an error as it was trying to do an array copy... so what's going on and what does that definition actually mean ?
mapNode[6]* can be read right-to-left as 'a pointer to an array of 6 mapNodes'.
For simplicity, let's use int instead of mapNode:
unittest {
int[6]* p;
int[6] arr;
p = &arr;
(*p)[0] = 1;
(*p)[1] = 2;
(*p)[2] = 3;
(*p)[3] = 4;
(*p)[4] = 5;
(*p)[5] = 6;
assert(arr == [1,2,3,4,5,6]);
}
--
Simen
|
October 10, 2018 Re: typo mapNode[6]* exits; instead of mapNode*[6] exits; but whats it mean ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjærås | On Wednesday, 10 October 2018 at 13:36:20 UTC, Simen Kjærås wrote:
> mapNode[6]* can be read right-to-left as 'a pointer to an array
right... hence the failed attempt at an array copy... now I understand...
|
Copyright © 1999-2021 by the D Language Foundation