068_comptime3.patch 741 B

1234567891011121314151617181920
  1. --- exercises/068_comptime3.zig 2023-10-03 22:15:22.125574535 +0200
  2. +++ answers/068_comptime3.zig 2023-10-05 20:04:07.149435295 +0200
  3. @@ -43,7 +43,7 @@
  4. //
  5. // Please change this so that it sets a 0 scale to 1
  6. // instead.
  7. - if (my_scale == 0) @compileError("Scale 1:0 is not valid!");
  8. + if (my_scale == 0) my_scale = 1; //@compileError("Scale 1:0 is not valid!");
  9. self.scale = my_scale;
  10. self.hull_length /= my_scale;
  11. @@ -69,7 +69,7 @@
  12. // Hey, we can't just pass this runtime variable as an
  13. // argument to the scaleMe() method. What would let us do
  14. // that?
  15. - var scale: u32 = undefined;
  16. + comptime var scale: u32 = undefined;
  17. scale = 32; // 1:32 scale