073_comptime8.patch 670 B

1234567891011121314151617
  1. --- exercises/073_comptime8.zig 2023-10-03 22:15:22.125574535 +0200
  2. +++ answers/073_comptime8.zig 2023-10-05 20:04:07.172769065 +0200
  3. @@ -32,12 +32,12 @@
  4. pub fn main() void {
  5. // We meant to fetch the last llama. Please fix this simple
  6. // mistake so the assertion no longer fails.
  7. - const my_llama = getLlama(5);
  8. + const my_llama = getLlama(4);
  9. print("My llama value is {}.\n", .{my_llama});
  10. }
  11. -fn getLlama(i: usize) u32 {
  12. +fn getLlama(comptime i: usize) u32 {
  13. // We've put a guard assert() at the top of this function to
  14. // prevent mistakes. The 'comptime' keyword here means that
  15. // the mistake will be caught when we compile!