質問

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