문제

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

struct MyStruct {
    ubyte[] a = {1, 2, 3, 4}; // Will Fail
}
도움이 되었습니까?

해결책

Try square brackets:

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

Here is the syntax for array literals.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top