golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.55k stars 519 forks source link

tour: An incorrect return value for flowcontrol example 1 #1484

Closed madamowicz closed 1 year ago

madamowicz commented 1 year ago

Context: https://go.dev/tour/flowcontrol/1

Not sure why, but when I run the code in this example (in the web browser as it is) it returns 45 instead of 10

crisman commented 1 year ago
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 == 45

45 is the expected output.

madamowicz commented 1 year ago

OMG, you are obviously right. It was too early in the morning and I wore sum += 1 :facepalm: Forgive me that.