From ce1a6ed98a70a20f17c387a54bc1691bc946af51 Mon Sep 17 00:00:00 2001 From: Chris James Date: Fri, 21 Jun 2024 09:52:58 +0100 Subject: [PATCH] fixes #759 --- hello-world.md | 2 ++ integers.md | 4 ++-- maps.md | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hello-world.md b/hello-world.md index fc13b23a..c0a1c021 100644 --- a/hello-world.md +++ b/hello-world.md @@ -316,6 +316,8 @@ For helper functions, it's a good idea to accept a `testing.TB` which is an inte `t.Helper()` is needed to tell the test suite that this method is a helper. By doing this, when it fails, the line number reported will be in our _function call_ rather than inside our test helper. This will help other developers track down problems more easily. If you still don't understand, comment it out, make a test fail and observe the test output. Comments in Go are a great way to add additional information to your code, or in this case, a quick way to tell the compiler to ignore a line. You can comment out the `t.Helper()` code by adding two forward slashes `//` at the beginning of the line. You should see that line turn grey or change to another color than the rest of your code to indicate it's now commented out. +When you have more than one argument of the same type \(in our case two strings\) rather than having `(got string, want string)` you can shorten it to `(got, want string)`. + ### Back to source control Now that we are happy with the code, I would amend the previous commit so that we only check in the lovely version of our code with its test. diff --git a/integers.md b/integers.md index 32240ab5..ae871440 100644 --- a/integers.md +++ b/integers.md @@ -63,9 +63,9 @@ func Add(x, y int) int { } ``` -When you have more than one argument of the same type \(in our case two integers\) rather than having `(x int, y int)` you can shorten it to `(x, y int)`. +Remember, when you have more than one argument of the same type \(in our case two integers\) rather than having `(x int, y int)` you can shorten it to `(x, y int)`. -Now run the tests and we should be happy that the test is correctly reporting what is wrong. +Now run the tests, and we should be happy that the test is correctly reporting what is wrong. `adder_test.go:10: expected '4' but got '0'` diff --git a/maps.md b/maps.md index ff8498d9..b66fefa5 100644 --- a/maps.md +++ b/maps.md @@ -595,7 +595,7 @@ func TestDelete(t *testing.T) { dictionary.Delete(word) _, err := dictionary.Search(word) - assertError(t, word, ErrNotFound) + assertError(t, word, ErrNotFound) } ```