#Type does not support array initialization syntax
1 messages · Page 1 of 1 (latest)
Yep, you can't initialize structs with array init syntax. Your main options are:
- specify all the field names, as in
.{ .input = "!5;", .operator = "!", .int_lit = 5 } - make a trivial constructor, so you can write
TestCase.init("!5;", "!", 5) - use tuples:
const TestCase = struct { []const u8, []const u8, i64 };
// then the declaration you gave works
(Minor note: standard naming conventions in Zig are to use snake_case for most variables and fields, so it'd be int_lit)
Thanks a lot. I was actually using the tuples and though it would be easier instead using index in my test. regarding the the naming convention I am currently lost on the rules so if there is place to read all the rules I would be happy. At the moment i have seen pascal case in some context but i don't know when to use snake case over pascal case.