Pregunta

How to automatically initialize a member array of a structure in D?

struct MyStruct {
    ubyte[] a = {1, 2, 3, 4}; // Will Fail
}
¿Fue útil?

Solución

Try square brackets:

struct MyStruct {
    ubyte[] a = [1, 2, 3, 4]; // Compiles
}

Here is the syntax for array literals.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top