aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/struct_default_field_values.zig
blob: 0ec34f9deda57b15d73595386e8bf02a7aba2288 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const Foo = struct {
    a: i32 = 1234,
    b: i32,
};

test "default struct initialization fields" {
    const x: Foo = .{
        .b = 5,
    };
    if (x.a + x.b != 1239) {
        comptime unreachable;
    }
}

// test