From 376ec9ac05cceee91d2a55c3aab34639a6817842 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Thu, 13 Jun 2024 15:37:47 -0400 Subject: [PATCH] 080-083 completed --- exercises/080_anonymous_structs.zig | 4 ++-- exercises/081_anonymous_structs2.zig | 2 +- exercises/082_anonymous_structs3.zig | 10 +++++----- exercises/083_anonymous_lists.zig | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/exercises/080_anonymous_structs.zig b/exercises/080_anonymous_structs.zig index 55dedd4..615267a 100644 --- a/exercises/080_anonymous_structs.zig +++ b/exercises/080_anonymous_structs.zig @@ -48,13 +48,13 @@ pub fn main() void { // * circle1 should hold i32 integers // * circle2 should hold f32 floats // - const circle1 = ??? { + const circle1 = Circle(i32){ .center_x = 25, .center_y = 70, .radius = 15, }; - const circle2 = ??? { + const circle2 = Circle(f32){ .center_x = 25.234, .center_y = 70.999, .radius = 15.714, diff --git a/exercises/081_anonymous_structs2.zig b/exercises/081_anonymous_structs2.zig index df78713..0b84438 100644 --- a/exercises/081_anonymous_structs2.zig +++ b/exercises/081_anonymous_structs2.zig @@ -38,7 +38,7 @@ pub fn main() void { // Please complete this function which prints an anonymous struct // representing a circle. -fn printCircle(???) void { +fn printCircle(circle: anytype) void { print("x:{} y:{} radius:{}\n", .{ circle.center_x, circle.center_y, diff --git a/exercises/082_anonymous_structs3.zig b/exercises/082_anonymous_structs3.zig index 6760ff3..ed6ab7c 100644 --- a/exercises/082_anonymous_structs3.zig +++ b/exercises/082_anonymous_structs3.zig @@ -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}\"({any}):{any} ", .{ - field.???, - field.???, - ???, + field.name, + field.type, + @field(tuple, field.name), }); } } diff --git a/exercises/083_anonymous_lists.zig b/exercises/083_anonymous_lists.zig index daaeaff..82d008a 100644 --- a/exercises/083_anonymous_lists.zig +++ b/exercises/083_anonymous_lists.zig @@ -20,6 +20,6 @@ pub fn main() void { // // = .{ 'h', 'e', 'l', 'l', 'o' }; // - const hello = .{ 'h', 'e', 'l', 'l', 'o' }; + const hello: [5]u8 = .{ 'h', 'e', 'l', 'l', 'o' }; print("I say {s}!\n", .{hello}); }