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

"hello world" text should explain the difference between := vs. = #622

Open
meleu opened this issue Nov 24, 2022 · 2 comments
Open

"hello world" text should explain the difference between := vs. = #622

meleu opened this issue Nov 24, 2022 · 2 comments

Comments

@meleu
Copy link

meleu commented Nov 24, 2022

First of all! Huge thank you for this amazing material! I'm new to TDD and Golang and I'm learning a lot! ❤️


As a person who has some years of experience with other programming languages but zero knowledge about Golang, I was a little surprised/confused when I saw statements like these ones:

  prefix := englishHelloPrefix
  prefix = spanishHelloPrefix

I googled and learned that we use:

In order to prevent people from having to leave the book to research this information, I suggest to put a short explanation about that in the text of the "Hello, World" chapter.

This can be especially enlightening for people coming from some interpreted languages background, where there's no clear difference between "declaration" and "assignment".

@Brivan-26
Copy link

He mentioned it in the iteration chapter. But yes, it would be nicer if it was introduced in Hello world chapter

@abhishekdas29
Copy link

The example given in hello world chapter is tricky since the prefix is defined as a named return parameter and thus is initialised automatically. However it does talk about an important aspect of when to use named return parameters as described in https://go.dev/tour/basics/7.

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