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

diff source book and online book #62

Open
moonrich opened this issue Jul 28, 2016 · 2 comments
Open

diff source book and online book #62

moonrich opened this issue Jul 28, 2016 · 2 comments

Comments

@moonrich
Copy link

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

@rstrlcpy
Copy link

still not fixed

@l0010o0001l
Copy link

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

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

3 participants