Open moonrich opened 8 years ago
still not fixed
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