content: rename variable names stringer exercise
Presumably n was for name, but it wasn't immediately clear
since "name" was not mentioned anywhere in the code example.
There was a bit of discussion about whether it should be called
k (for key) or s (for string) or h (for host).
It seems like a lot of the confusion stems from the map being named
addrs, while actually containing both the name and the ip address of
the hosts.
Change-Id: Idf4483f142831b375cb0b1a5ebd58e8f3d9df30b
Reviewed-on: https://go-review.googlesource.com/19405
Reviewed-by: Andrew Gerrand <adg@golang.org>
diff --git a/content/methods/exercise-stringer.go b/content/methods/exercise-stringer.go
index 11fc7b5..bd9fed5 100644
--- a/content/methods/exercise-stringer.go
+++ b/content/methods/exercise-stringer.go
@@ -9,11 +9,11 @@
// TODO: Add a "String() string" method to IPAddr.
func main() {
- addrs := map[string]IPAddr{
+ hosts := map[string]IPAddr{
"loopback": {127, 0, 0, 1},
"googleDNS": {8, 8, 8, 8},
}
- for n, a := range addrs {
- fmt.Printf("%v: %v\n", n, a)
+ for name, ip := range hosts {
+ fmt.Printf("%v: %v\n", name, ip)
}
}