How to pass in reference a fixed array in parameter

Nick Treleaven nick at geany.org
Wed Jun 5 10:36:50 UTC 2024


On Wednesday, 5 June 2024 at 10:27:47 UTC, Nick Treleaven wrote:
>    foreach (i, row; maze)
>        slices[i] = row;

Sorry that assignment was wrong (edited at last minute). Fixed:

```d
import std.stdio;
alias s_cell = int;

void main()
{  writeln("Maze generation demo");

    s_cell [5][5] maze;
    int n;
    foreach (i, row; maze)
         foreach (j, col; row)
             maze[i][j] = n++;

    s_cell[][5] slices;
    foreach (i, _; maze)
        slices[i] = maze[i];

    print_maze (slices);
}

void print_maze ( s_cell [][] maze )
{
     foreach (a; maze)
         a.writeln();
}
```


More information about the Digitalmars-d-learn mailing list