You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ziglings/patches/patches/068_comptime3.patch

21 lines
741 B
Diff

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