1
0
Fork 0
mirror of https://codeberg.org/ziglings/exercises.git synced 2025-06-08 01:57:02 +09:00

Converted var to const if there is no mutation in var.

This is checked from compiler version 0.12.0-dev.1664
This commit is contained in:
Chris Boesch 2023-11-21 15:01:22 +01:00
parent b7015c2d9d
commit 7679f93f68
21 changed files with 46 additions and 46 deletions

View file

@ -1,11 +1,11 @@
--- exercises/025_errors5.zig 2023-10-03 22:15:22.122241138 +0200
+++ answers/025_errors5.zig 2023-10-05 20:04:06.952764946 +0200
--- exercises/025_errors5.zig 2023-11-21 14:22:48.159250165 +0100
+++ answers/025_errors5.zig 2023-11-21 14:25:01.338277886 +0100
@@ -26,7 +26,7 @@
// This function needs to return any error which might come back from detect().
// Please use a "try" statement rather than a "catch".
//
- var x = detect(n);
+ var x = try detect(n);
- const x = detect(n);
+ const x = try detect(n);
return x + 5;
}

View file

@ -1,5 +1,5 @@
--- exercises/075_quiz8.zig 2023-10-03 22:15:22.125574535 +0200
+++ answers/075_quiz8.zig 2023-10-05 20:04:07.182769252 +0200
--- exercises/075_quiz8.zig 2023-11-21 14:48:15.440702720 +0100
+++ answers/075_quiz8.zig 2023-11-21 14:50:23.453311616 +0100
@@ -49,7 +49,11 @@
//
// Please fill in the body of this function!

View file

@ -1,18 +1,18 @@
--- exercises/080_anonymous_structs.zig 2023-10-03 22:15:22.125574535 +0200
+++ answers/080_anonymous_structs.zig 2023-10-05 20:04:07.202769626 +0200
--- exercises/080_anonymous_structs.zig 2023-11-21 14:52:54.312749682 +0100
+++ answers/080_anonymous_structs.zig 2023-11-21 14:52:43.909225238 +0100
@@ -48,13 +48,13 @@
// * circle1 should hold i32 integers
// * circle2 should hold f32 floats
//
- var circle1 = ??? {
+ var circle1 = Circle(i32){
- const circle1 = ??? {
+ const circle1 = Circle(i32){
.center_x = 25,
.center_y = 70,
.radius = 15,
};
- var circle2 = ??? {
+ var circle2 = Circle(f32){
- const circle2 = ??? {
+ const circle2 = Circle(f32){
.center_x = 25.234,
.center_y = 70.999,
.radius = 15.714,

View file

@ -1,11 +1,11 @@
--- exercises/096_memory_allocation.zig 2023-10-03 22:15:22.125574535 +0200
+++ answers/096_memory_allocation.zig 2023-10-05 20:04:07.276104333 +0200
--- exercises/096_memory_allocation.zig 2023-11-21 14:55:33.805678390 +0100
+++ answers/096_memory_allocation.zig 2023-11-21 14:56:00.236163484 +0100
@@ -64,7 +64,7 @@
const allocator = arena.allocator();
// allocate memory for this array
- var avg: []f64 = ???;
+ var avg: []f64 = try allocator.alloc(f64, arr.len);
- const avg: []f64 = ???;
+ const avg: []f64 = try allocator.alloc(f64, arr.len);
runningAverage(arr, avg);
std.debug.print("Running Average: ", .{});