This commit is contained in:
Adam Millerchip 2022-01-02 20:37:39 +09:00
parent 63c6d822d2
commit 09d95042cb
1 changed files with 5 additions and 5 deletions

View File

@ -82,14 +82,14 @@ fn printTuple(tuple: anytype) void {
// @typeInfo(Circle).Struct.fields
//
// This will be an array of StructFields.
const fields = ???;
const fields = @typeInfo(@TypeOf(tuple)).Struct.fields;
// 2. Loop through each field. This must be done at compile
// time.
//
// Hint: remember 'inline' loops?
//
for (fields) |field| {
inline for (fields) |field| {
// 3. Print the field's name, type, and value.
//
// Each 'field' in this loop is one of these:
@ -117,9 +117,9 @@ fn printTuple(tuple: anytype) void {
//
// The first field should print as: "0"(bool):true
print("\"{s}\"({s}):{any} ", .{
field.???,
field.???,
???,
field.name,
field.field_type,
@field(tuple, field.name),
});
}
}