Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Struct Initialization

Part of TutorialFundamentals

Description

Shows a quick way to initialize a struct.

Example

struct Foo
{
    int bar, baz, bam;
}

void main()
{
    static Foo[] myfoo =  [
      { 0, 1, 2 },
      { bar: 3, baz: 4, bam: 5 },
      { bam: 8, baz: 7, bar: 6 },
    ];
}

Source

Based on D/22815 by Vathix on 30 Jan 2004.