Filling an array at compile time

Vindex tech.vindex at
Wed Feb 9 08:12:52 UTC 2022

Will the loop (foreach) run at compile time? How can I make it 
work at compile time?

import std.csv, std.stdio;

alias Record = Tuple!(string, string, string);

immutable string[][] table;

shared static this() {
     string csvText = import("file.csv");
     foreach (record; csvReader!Record(csvText)) {
         table ~= [record[0], record[1], record[2]];

void main() {

More information about the Digitalmars-d-learn mailing list