WIP: comptime experiments

This commit is contained in:
Laurens Miers 2024-09-25 12:20:34 +02:00
parent 7417f01d5d
commit b68855fc2d
10 changed files with 57 additions and 15 deletions

View file

@ -43,7 +43,8 @@ const Schooner = struct {
//
// 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) @compileError("Scale 1:0 is not valid!");
if (my_scale == 0) my_scale = 1;
self.scale = my_scale;
self.hull_length /= my_scale;
@ -69,7 +70,7 @@ pub fn main() void {
// 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