ratfactor / ziglings

Learn the Zig programming language by fixing tiny broken programs.
MIT License
4.29k stars 485 forks source link

Change `var` to `const` in some exercises #329

Closed lorrding closed 1 year ago

lorrding commented 1 year ago

As explained in #324 , I changed some variable declaration to constants. I also tried to update the comments when it made sense. Some variable could be changed to constant like num1 here in 039_pointers.zig but it would require to also change num1_pointer to be *const u8. https://github.com/ratfactor/ziglings/blob/08e8a0f1e48954c4b4657c0078bb5b3ef0c8d13d/exercises/039_pointers.zig#L25-L36

Since this exercise is trying to explain how pointers works I assumed it would not be a good idea to make the change. The same applies to exercise 066_comptime.zig and after, where we already make use of const and comptime.

I also understand that changing variables to constants may give away the answer to some exercise. Feel free to not merge some changes to some exercises if you think it's not worth it.

Everything was built and run with zig 0.11.0-dev.3747

NB: I also updated outdated comments referencing the change in builtin casts as I forgot to check those in my previous PR. (see: #327)

chrboesch commented 1 year ago

Thanks!