#User struct using array initialization syntax
1 messages · Page 1 of 1 (latest)
you have to give the field names for this or you could create a function
or make the struct a tuple but i wouldnt argue for that
Seeing as it would be just a syntax nicety I don't think I'll bother and just use the specifiers, thanks
Most you can get is something like this```
const Version = struct {
major: u8,
minor: u8,
patch: u8,
fn init(major: u8, minor: u8, patch: u8) Version {
return .{
.major = major,
.minor = minor,
.patch = patch,
};
}
}
const v: Version = .init(1, 0, 0);```
Imo it's best to just use the field names