You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is sometimes useful to also print the inputs to the function in the error
43
43
message and we are using the `%v` placeholder which is the "default" format,
@@ -78,12 +78,12 @@ func Sum(numbers [5]int) int {
78
78
```
79
79
80
80
To get the value out of an array at a particular index, just use `array[index]`
81
-
syntax. In this case we are using `for` to iterate 5 times to work through the
81
+
syntax. In this case, we are using `for` to iterate 5 times to work through the
82
82
array and add each item onto `sum`.
83
83
84
84
### A note on source control
85
85
86
-
At this point if you are using source control \(which you should!\) I would
86
+
At this point, if you are using source control \(which you should!\) I would
87
87
`commit` the code as it is. We have working software backed by a test.
88
88
89
89
I _wouldn't_ push to master though, because I plan to refactor next. It is nice
@@ -199,7 +199,7 @@ It turns out that fixing the compiler problems were all we need to do here and t
199
199
200
200
## Refactor
201
201
202
-
We had already refactored `Sum` and all we've done is change from arrays to slices, so there's not a lot to do here. Remember that we must not neglect our test code in the refactoring stage and we have some to do here.
202
+
We had already refactored `Sum` and all we've done is changing from arrays to slices, so there's not a lot to do here. Remember that we must not neglect our test code in the refactoring stage and we have some to do here.
203
203
204
204
```go
205
205
funcTestSum(t *testing.T) {
@@ -258,7 +258,7 @@ coverage: 100.0% of statements
258
258
259
259
Now delete one of the tests and check the coverage again.
260
260
261
-
Now that we are happy we have a welltested function you should commit your
261
+
Now that we are happy we have a well-tested function you should commit your
262
262
great work before taking on the next challenge.
263
263
264
264
We need a new function called `SumAll` which will take a varying number of
@@ -275,7 +275,7 @@ or
275
275
## Write the test first
276
276
277
277
```go
278
-
funcTestSumAll(t *testing.T) {
278
+
funcTestSumAll(t *testing.T) {
279
279
280
280
got:=SumAll([]int{1,2}, []int{0,9})
281
281
want:= []int{3, 9}
@@ -308,11 +308,11 @@ Try to compile but our tests still don't compile!
308
308
309
309
Go does not let you use equality operators with slices. You _could_ write
310
310
a function to iterate over each `got` and `want` slice and check their values
311
-
but for convenience sake we can use [`reflect.DeepEqual`][deepEqual] which is
311
+
but for convenience sake, we can use [`reflect.DeepEqual`][deepEqual] which is
312
312
useful for seeing if _any_ two variables are the same.
313
313
314
314
```go
315
-
funcTestSumAll(t *testing.T) {
315
+
funcTestSumAll(t *testing.T) {
316
316
317
317
got:=SumAll([]int{1,2}, []int{0,9})
318
318
want:= []int{3, 9}
@@ -330,7 +330,7 @@ will compile even if you did something a bit silly. To see this in action,
0 commit comments