···42424343```bash
4444$ zig version
4545-0.11.0-dev.1650+xxxxxxxxx
4545+0.11.0-dev.11711+xxxxxxxxx
4646```
47474848Clone this repository with Git:
···82828383### Version Changes
84848585-Version-0.11.0-dev.1650+xxxxxxxxx
8585+Version-0.11.0-dev.11711+xxxxxxxxx
8686+* *2023-02-21* zig 0.11.0-dev.1711 - changes in `for loops` - new: Multi Object For Loops + Struct-of-Arrays
8687* *2023-02-12* zig 0.11.0-dev.1638 - changes in `std.Build` cache_root now returns a directory struct
8788* *2023-02-04* zig 0.11.0-dev.1568 - changes in `std.Build` (combine `std.build` and `std.build.Builder` into `std.Build`)
8889* *2023-01-14* zig 0.11.0-dev.1302 - changes in `@addWithOverflow` (now returns a tuple) and `@typeInfo`; temporary disabled async functionality
+1-1
build.zig
···88// When changing this version, be sure to also update README.md in two places:
99// 1) Getting Started
1010// 2) Version Changes
1111-const needed_version = std.SemanticVersion.parse("0.11.0-dev.1650") catch unreachable;
1111+const needed_version = std.SemanticVersion.parse("0.11.0-dev.1711") catch unreachable;
12121313const Exercise = struct {
1414 /// main_file must have the format key_name.zig.
+6-5
exercises/016_for2.zig
···11//
22-// For loops also let you store the "index" of the iteration - a
33-// number starting with 0 that counts up with each iteration:
22+// For loops also let you use the "index" of the iteration, a number
33+// that counts up with each iteration. To access the index of iteration,
44+// specify a second condition as well as a second capture value.
45//
55-// for (items) |item, index| {
66+// for (items, 0..) |item, index| {
67//
78// // Do something with item and index
89//
···2324 // Now we'll convert the binary bits to a number value by adding
2425 // the value of the place as a power of two for each bit.
2526 //
2626- // See if you can figure out the missing piece:
2727- for (bits) |bit, ???| {
2727+ // See if you can figure out the missing pieces:
2828+ for (bits, ???) |bit, ???| {
2829 // Note that we convert the usize i to a u32 with
2930 // @intCast(), a builtin function just like @import().
3031 // We'll learn about these properly in a later exercise.
+1-1
exercises/038_structs2.zig
···4444 // it do and why?
45454646 // Printing all RPG characters in a loop:
4747- for (chars) |c, num| {
4747+ for (chars, 0..) |c, num| {
4848 std.debug.print("Character {} - G:{} H:{} XP:{}\n", .{
4949 num + 1, c.gold, c.health, c.experience,
5050 });
+1-1
exercises/047_methods.zig
···8686 aliens_alive = 0;
87878888 // Loop through every alien by reference (* makes a pointer capture value)
8989- for (aliens) |*alien| {
8989+ for (&aliens) |*alien| {
90909191 // *** Zap the alien with the heat ray here! ***
9292 ???.zap(???);
+1-1
exercises/058_quiz7.zig
···239239 // We'll often want to find an entry by Place. If one is not
240240 // found, we return null.
241241 fn getEntry(self: *HermitsNotebook, place: *const Place) ?*NotebookEntry {
242242- for (self.entries) |*entry, i| {
242242+ for (&self.entries, 0..) |*entry, i| {
243243 if (i >= self.end_of_entries) break;
244244245245 // Here's where the hermit got stuck. We need to return
+1-1
exercises/063_labels.zig
···106106 const meal = food_loop: for (menu) |food| {
107107108108 // Now look at each required ingredient for the Food...
109109- for (food.requires) |required, required_ingredient| {
109109+ for (food.requires, 0..) |required, required_ingredient| {
110110111111 // This ingredient isn't required, so skip it.
112112 if (!required) continue;
+1-1
exercises/075_quiz8.zig
···102102 end_of_entries: u8 = 0,
103103104104 fn getEntry(self: *HermitsNotebook, place: *const Place) ?*NotebookEntry {
105105- for (self.entries) |*entry, i| {
105105+ for (&self.entries, 0..) |*entry, i| {
106106 if (i >= self.end_of_entries) break;
107107 if (place == entry.*.?.place) return &entry.*.?;
108108 }
+3-3
patches/patches/016_for2.patch
···11-27c27
22-< for (bits) |bit, ???| {
11+28c28
22+< for (bits, ???) |bit, ???| {
33---
44-> for (bits) |bit, i| {
44+> for (bits, 0..) |bit, i| {