diff --git a/exercises/069_comptime4.zig b/exercises/069_comptime4.zig index e090bb3..4afbddf 100644 --- a/exercises/069_comptime4.zig +++ b/exercises/069_comptime4.zig @@ -1,11 +1,9 @@ // -// One of the more common uses of 'comptime' function parameters is -// passing a type to a function: +// In Zig types are first class values // -// fn foo(comptime MyType: type) void { ... } +// fn foo(MyType: type) void { ... } // -// In fact, types are ONLY available at compile time, so the -// 'comptime' keyword is required here. +// Types are resolved at compile time. // // Please take a moment to put on the wizard hat which has been // provided for you. We're about to use this ability to implement @@ -42,7 +40,7 @@ pub fn main() void { // 2) Sets the size of the array of type T (which is the // sequence we're creating and returning). // -fn makeSequence(comptime T: type, ??? size: usize) [???]T { +fn makeSequence(T: type, ??? size: usize) [???]T { var sequence: [???]T = undefined; var i: usize = 0; diff --git a/exercises/080_anonymous_structs.zig b/exercises/080_anonymous_structs.zig index 55dedd4..333802c 100644 --- a/exercises/080_anonymous_structs.zig +++ b/exercises/080_anonymous_structs.zig @@ -31,7 +31,7 @@ const print = @import("std").debug.print; // This function creates a generic data structure by returning an // anonymous struct type (which will no longer be anonymous AFTER // it's returned from the function). -fn Circle(comptime T: type) type { +fn Circle(T: type) type { return struct { center_x: T, center_y: T, diff --git a/patches/patches/069_comptime4.patch b/patches/patches/069_comptime4.patch index 2b61673..1ba5ffa 100644 --- a/patches/patches/069_comptime4.patch +++ b/patches/patches/069_comptime4.patch @@ -4,9 +4,9 @@ // 2) Sets the size of the array of type T (which is the // sequence we're creating and returning). // --fn makeSequence(comptime T: type, ??? size: usize) [???]T { +-fn makeSequence(T: type, ??? size: usize) [???]T { - var sequence: [???]T = undefined; -+fn makeSequence(comptime T: type, comptime size: usize) [size]T { ++fn makeSequence(T: type, comptime size: usize) [size]T { + var sequence: [size]T = undefined; var i: usize = 0;