diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | exercises/04_arrays.zig | 6 | ||||
-rw-r--r-- | exercises/10_if2.zig | 2 |
3 files changed, 9 insertions, 7 deletions
@@ -1,13 +1,15 @@ # ziglings -Welcome to `ziglings`! This project contains a series of incomplete exercises. -By completing the exercises, you learn how to read and write +Welcome to `ziglings`! This project contains a series of tiny broken programs. +By fixing them, you'll learn how to read and write [Zig](https://ziglang.org/) -code. +code! This project was directly inspired by the brilliant and fun [rustlings](https://github.com/rust-lang/rustlings) project for the [Rust](https://www.rust-lang.org/) language. +Indirect inspiration comes from [Ruby Koans]( http://rubykoans.com/) +and the Little LISPer/Little Schemer series of books. ## Intended Audience diff --git a/exercises/04_arrays.zig b/exercises/04_arrays.zig index 0f4ffe1..c1e9fd9 100644 --- a/exercises/04_arrays.zig +++ b/exercises/04_arrays.zig @@ -1,7 +1,7 @@ // // Let's learn some array basics. Arrays are declared with: // -// var foo [3]u32 = [3]u32{ 42, 108, 5423 }; +// var foo: [3]u32 = [3]u32{ 42, 108, 5423 }; // // When Zig can infer the size of the array, you can use '_' for the // size. You can also let Zig infer the type of the value so the @@ -11,11 +11,11 @@ // // Get values of an array using array[index] notation: // -// const bar = foo[3]; // 5423 +// const bar = foo[2]; // 5423 // // Set values of an array using array[index] notation: // -// foo[3] = 16; +// foo[2] = 16; // // Get the length of an array using the len property: // diff --git a/exercises/10_if2.zig b/exercises/10_if2.zig index 0925d18..ba9c2df 100644 --- a/exercises/10_if2.zig +++ b/exercises/10_if2.zig @@ -10,7 +10,7 @@ pub fn main() void { // Please use an if...else expression to set "price". // If discount is true, the price should be $17, otherwise $20: - var price = if ???; + var price: u8 = if ???; std.debug.print("With the discount, the price is ${}.\n", .{price}); } |