Merge pull request 'Converted var to const if there is no mutation in the var.' (#28) from var_const into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/28pull/29/head
commit
f987a06ccc
@ -1,11 +1,11 @@
|
|||||||
--- exercises/025_errors5.zig 2023-10-03 22:15:22.122241138 +0200
|
--- exercises/025_errors5.zig 2023-11-21 14:22:48.159250165 +0100
|
||||||
+++ answers/025_errors5.zig 2023-10-05 20:04:06.952764946 +0200
|
+++ answers/025_errors5.zig 2023-11-21 14:25:01.338277886 +0100
|
||||||
@@ -26,7 +26,7 @@
|
@@ -26,7 +26,7 @@
|
||||||
// This function needs to return any error which might come back from detect().
|
// This function needs to return any error which might come back from detect().
|
||||||
// Please use a "try" statement rather than a "catch".
|
// Please use a "try" statement rather than a "catch".
|
||||||
//
|
//
|
||||||
- var x = detect(n);
|
- const x = detect(n);
|
||||||
+ var x = try detect(n);
|
+ const x = try detect(n);
|
||||||
|
|
||||||
return x + 5;
|
return x + 5;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
--- exercises/080_anonymous_structs.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/080_anonymous_structs.zig 2023-11-21 14:52:54.312749682 +0100
|
||||||
+++ answers/080_anonymous_structs.zig 2023-10-05 20:04:07.202769626 +0200
|
+++ answers/080_anonymous_structs.zig 2023-11-21 14:52:43.909225238 +0100
|
||||||
@@ -48,13 +48,13 @@
|
@@ -48,13 +48,13 @@
|
||||||
// * circle1 should hold i32 integers
|
// * circle1 should hold i32 integers
|
||||||
// * circle2 should hold f32 floats
|
// * circle2 should hold f32 floats
|
||||||
//
|
//
|
||||||
- var circle1 = ??? {
|
- const circle1 = ??? {
|
||||||
+ var circle1 = Circle(i32){
|
+ const circle1 = Circle(i32){
|
||||||
.center_x = 25,
|
.center_x = 25,
|
||||||
.center_y = 70,
|
.center_y = 70,
|
||||||
.radius = 15,
|
.radius = 15,
|
||||||
};
|
};
|
||||||
|
|
||||||
- var circle2 = ??? {
|
- const circle2 = ??? {
|
||||||
+ var circle2 = Circle(f32){
|
+ const circle2 = Circle(f32){
|
||||||
.center_x = 25.234,
|
.center_x = 25.234,
|
||||||
.center_y = 70.999,
|
.center_y = 70.999,
|
||||||
.radius = 15.714,
|
.radius = 15.714,
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
--- exercises/096_memory_allocation.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/096_memory_allocation.zig 2023-11-21 14:55:33.805678390 +0100
|
||||||
+++ answers/096_memory_allocation.zig 2023-10-05 20:04:07.276104333 +0200
|
+++ answers/096_memory_allocation.zig 2023-11-21 14:56:00.236163484 +0100
|
||||||
@@ -64,7 +64,7 @@
|
@@ -64,7 +64,7 @@
|
||||||
const allocator = arena.allocator();
|
const allocator = arena.allocator();
|
||||||
|
|
||||||
// allocate memory for this array
|
// allocate memory for this array
|
||||||
- var avg: []f64 = ???;
|
- const avg: []f64 = ???;
|
||||||
+ var avg: []f64 = try allocator.alloc(f64, arr.len);
|
+ const avg: []f64 = try allocator.alloc(f64, arr.len);
|
||||||
|
|
||||||
runningAverage(arr, avg);
|
runningAverage(arr, avg);
|
||||||
std.debug.print("Running Average: ", .{});
|
std.debug.print("Running Average: ", .{});
|
||||||
|
Loading…
Reference in New Issue