3 ms·
One will quickly become accustomed to the .{} pattern learning Zig. It's used for struct constructors: const a_struct: StructType = .{ .foo = "baz"}; As w
by samatman 2y ago
One will quickly become accustomed to the .{} pattern learning Zig. It's used for struct constructors:
const a_struct: StructType = .{ .foo = "baz"};
As well as union initialization. So .{} is a struct constructor for a struct where every field has a default value, which chooses all of those fields.
- flohofwoe 2y agoI think it becomes clearer when considering that these are all equivalent: const a_struct: StructType = StructType{ .foo = "baz" }; const a_struct = StructType{ .foo = "baz" }; const a_struct: StructType = .{ .foo = "baz" };