golang / tour

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

tour: [Switch Evaluation Order] #1068

Open 37signs opened 4 years ago

37signs commented 4 years ago

Context: http://127.0.0.1:3999/flowcontrol/10

Needed to mod the switch statements in order for this snippet to work towards the end of the week.

case (today + 1) % 7:
    fmt.Println("Tomorrow.")
crisman commented 1 year ago

That should never be needed as the lower (today + 0) test is higher in the case list.

You may have missed the note about the odd time (always a Tuesday) in the Go Playground if you used the online tour:

Note: Time in the Go playground always appears to start at 2009-11-10 23:00:00 UTC, a value whose significance is left as an exercise for the reader.