Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 2.7 Code Example is Incorrect #71

Open
SErvin4390 opened this issue Jun 13, 2018 · 0 comments
Open

Chapter 2.7 Code Example is Incorrect #71

SErvin4390 opened this issue Jun 13, 2018 · 0 comments

Comments

@SErvin4390
Copy link

In the book, the example is shown as

`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)
}`

But, the Go Playground shows

`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)
}
`

The Playground seems to be more correct than the code shown in the book text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant