I don’t see any differences in this code. This is from Tood McLeod course, right?
One difference is in inside of for loop. You are printing record id and values
You did very well with that! It looks like there is just one little bug.
In addition to what Johan pointed out, there is this:
for j, val := range rt {
does something different than
for j, val := range xs {
Notice that it is xs here, not xxs. So the results are different. Your version prints only two of the three strings in each slice. Change rt to v in your code, and it will print all three.
You’re right. Todd McLeod.
You’re also right about the second statement. I don’t understand the difference between
fmt.Println(“record”, i, v) and fmt.Println("record: ", i)
It’s the button next to Share button in go playground. It changes how the program is formatted so it follows the usual way of formatting go programs. How many spaces here and there and so on
Here is your program at the Go Playground, with the change I suggested:
Look at the second for loop. I changed range rt to range v to make it work more like the teacher’s solution. Try running it. Now it will print all three strings in each of the two slices.
They are just variable names, so you can use anything you want. The ones he chose weren’t very descriptive! It’s best to use variable names that help show what they are used for, to make your code easy to understand.