You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To chime in, an example of the published version's content being different than the source code is the example code after the sentence, "If the result parameters are named, a return statement without arguments returns the current values of the results.":
Published:
func location(name, city string) (region, continent string) {
switch city {
case "New York", "LA", "Chicago":
continent = "North America"
default:
continent = "Unknown"
}
return
}
func main() {
region, continent := location("Matt", "LA")
fmt.Printf("%s lives in %s", region, continent)
}
Source (and also in Go Playground):
package main
import "fmt"
func location(city string) (region, continent string) {
switch city {
case "Los Angeles", "LA", "Santa Monica":
region, continent = "California", "North America"
case "New York", "NYC":
region, continent = "New York", "North America"
default:
region, continent = "Unknown", "Unknown"
}
return
}
func main() {
region, continent := location("Santa Monica")
fmt.Printf("Matt lives in %s, %s", region, continent)
}
Please compile new version for online book
I found,
Chapter 2: The Basics |> 2.7 Functions, signature, return values, named results
The content of online book , still old than source book
The text was updated successfully, but these errors were encountered: