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

why it is not error? #42939

Closed
aloska opened this issue Dec 2, 2020 · 2 comments
Closed

why it is not error? #42939

aloska opened this issue Dec 2, 2020 · 2 comments

Comments

@aloska
Copy link

aloska commented Dec 2, 2020

func main() {
	n:=1608
	for i := 0; i < 20; i++ {
		n:="what do you do"
	    //  ^ - why it is not error?
		fmt.Print(n)
	}
	fmt.Print(n)
}

In a strongly typed language, this behavior of the compiler is not expected, as for me. Or?
Because if I do something like this:

func main() {
	n:=1608
	for i := 0; i < 20; i++ {
		n:=i*n
	    //  ^ - why it is not error?
		fmt.Print(n)
	}
	fmt.Print(n)
}

I expected another behavior with my mistake of ":=" - creating new var instead "=" using existing var
So it's mistake should be non-compiled I hope)))

@davecheney
Copy link
Contributor

Thank you for raising this issue. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For asking questions, see:

@aloska aloska closed this as completed Dec 2, 2020
@aloska
Copy link
Author

aloska commented Dec 2, 2020

OK, thanks)

@golang golang locked and limited conversation to collaborators Dec 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants