diff options
| author | Dave Gauer <[email protected]> | 2022-08-29 18:30:38 -0400 |
|---|---|---|
| committer | Dave Gauer <[email protected]> | 2022-08-29 18:30:38 -0400 |
| commit | 4eaef5fae41f3c15b2e45240c9a57d2c2740c5e3 (patch) | |
| tree | 29cc1a6125123e43bd313c23e270adb186c3cf11 /patches | |
| parent | 4ce16782d02ec30a395e6300c6ebd05734febc55 (diff) | |
| download | ziglings-4eaef5fae41f3c15b2e45240c9a57d2c2740c5e3.tar.xz ziglings-4eaef5fae41f3c15b2e45240c9a57d2c2740c5e3.zip | |
Ex 065: improve hints, fix type printing change. For #120 and #128
Diffstat (limited to 'patches')
| -rw-r--r-- | patches/patches/065_builtins2.patch | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/patches/patches/065_builtins2.patch b/patches/patches/065_builtins2.patch index 1c2acf5..9c1bf76 100644 --- a/patches/patches/065_builtins2.patch +++ b/patches/patches/065_builtins2.patch @@ -1,26 +1,39 @@ -43c43 -< const print = import(std).debug.print; // Oops! ---- -> const print = @import("std").debug.print; -60,61c60,61 -< ??? = &narcissus; -< ??? = &narcissus; ---- -> narcissus.me = &narcissus; -> narcissus.myself = &narcissus; -71c71 -< const T2 = narcissus.fetchTheMostBeautifulType(); ---- -> const T2 = Narcissus.fetchTheMostBeautifulType(); -106c106 -< if (fields[0].??? != void) { ---- -> if (fields[0].field_type != void) { -110c110 -< if (fields[1].??? != void) { ---- -> if (fields[1].field_type != void) { -114c114 -< if (fields[2].??? != void) { ---- -> if (fields[2].field_type != void) { +--- exercises/065_builtins2.zig ++++ answers/065_builtins2.zig +@@ -58,7 +58,7 @@ + // Oops! We cannot leave the 'me' and 'myself' fields + // undefined. Please set them here: + narcissus.me = &narcissus; +- narcissus.??? = ???; ++ narcissus.myself = &narcissus; + + // This determines a "peer type" from three separate + // references (they just happen to all be the same object). +@@ -70,7 +70,7 @@ + // + // The fix for this is very subtle, but it makes a big + // difference! +- const Type2 = narcissus.fetchTheMostBeautifulType(); ++ const Type2 = Narcissus.fetchTheMostBeautifulType(); + + // Now we print a pithy statement about Narcissus. + print("A {s} loves all {s}es. ", .{ +@@ -109,15 +109,15 @@ + // Please complete these 'if' statements so that the field + // name will not be printed if the field is of type 'void' + // (which is a zero-bit type that takes up no space at all!): +- if (fields[0].??? != void) { ++ if (fields[0].field_type != void) { + print(" {s}", .{@typeInfo(Narcissus).Struct.fields[0].name}); + } + +- if (fields[1].??? != void) { ++ if (fields[1].field_type != void) { + print(" {s}", .{@typeInfo(Narcissus).Struct.fields[1].name}); + } + +- if (fields[2].??? != void) { ++ if (fields[2].field_type != void) { + print(" {s}", .{@typeInfo(Narcissus).Struct.fields[2].name}); + } + |
