diff options
author | Dave Gauer <dave@ratfactor.com> | 2021-04-10 14:45:25 -0400 |
---|---|---|
committer | Dave Gauer <dave@ratfactor.com> | 2021-04-10 14:45:25 -0400 |
commit | 4251076b50082023f609e2823b143993f7749b57 (patch) | |
tree | 8e307b81417a4755b78d18f34ecfef6777964baa | |
parent | 88a8f4788db2fde6f8e957abe3fceacf530d011c (diff) | |
download | ziglings-4251076b50082023f609e2823b143993f7749b57.tar.gz ziglings-4251076b50082023f609e2823b143993f7749b57.tar.bz2 ziglings-4251076b50082023f609e2823b143993f7749b57.tar.xz ziglings-4251076b50082023f609e2823b143993f7749b57.zip |
mention builtin ex coming up
-rw-r--r-- | exercises/016_for2.zig | 3 | ||||
-rw-r--r-- | exercises/036_enums2.zig | 4 | ||||
-rw-r--r-- | exercises/058_quiz7.zig | 5 |
3 files changed, 10 insertions, 2 deletions
diff --git a/exercises/016_for2.zig b/exercises/016_for2.zig index 0a62a1a..1d4496a 100644 --- a/exercises/016_for2.zig +++ b/exercises/016_for2.zig @@ -25,6 +25,9 @@ pub fn main() void { // // See if you can figure out the missing piece: for (bits) |bit, ???| { + // Note that we convert the usize i to a u32 with + // @intCast(), a builtin function just like @import(). + // We'll learn about these properly in a later exercise. var place_value = std.math.pow(u32, 2, @intCast(u32, i)); value += place_value * bit; } diff --git a/exercises/036_enums2.zig b/exercises/036_enums2.zig index e6337e9..820a71e 100644 --- a/exercises/036_enums2.zig +++ b/exercises/036_enums2.zig @@ -5,7 +5,9 @@ // // const Stuff = enum(u8){ foo = 16 }; // -// You can get the integer out with a built-in function: +// You can get the integer out with a builtin function, +// @enumToInt(). We'll learn about builtins properly in a later +// exercise. // // var my_stuff: u8 = @enumToInt(Stuff.foo); // diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig index 46d68a8..59b48ba 100644 --- a/exercises/058_quiz7.zig +++ b/exercises/058_quiz7.zig @@ -419,7 +419,10 @@ pub fn main() void { // we need to loop through the items in reverse, skipping nulls, until // we reach the destination at the front of the array. fn printTrip(trip: []?TripItem) void { - var i: u8 = @intCast(u8, trip.len); // convert usize length + // We convert the usize length to a u8 with @intCast(), a + // builtin function just like @import(). We'll learn about + // these properly in a later exercise. + var i: u8 = @intCast(u8, trip.len); while (i > 0) { i -= 1; |