Issue De-referencing a Pointer to a Struct in an Array

Steven Schveighoffer schveiguy at gmail.com
Fri Jul 14 18:36:27 UTC 2023


On 7/14/23 1:23 PM, Pen Hall wrote:

> I think i figured out my issue...
> The issue was that 'board' is a pointer, and all of the ways I tried to 
> de-reference it, failed. I just tried the form 
> `(*board)[number][symbol][letter]` which worked to de-reference it. 
> `&(*board)[number][symbol][letter]`, of course, works to get a pointer 
> to that spot in memory.

A nice abstraction available in D is a nested function.

e.g.:

```d
ref boardRef => *board;
// or with traditional syntax:
ref Tile[8][8][8] boardRef() { return *board; }
```

This should allow you to use `boardRef[number][symbol][i]`

-Steve


More information about the Digitalmars-d-learn mailing list