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

Update your golang_refcard.pdf, please #78

Open
appak21 opened this issue Oct 22, 2022 · 1 comment
Open

Update your golang_refcard.pdf, please #78

appak21 opened this issue Oct 22, 2022 · 1 comment

Comments

@appak21
Copy link

appak21 commented Oct 22, 2022

outer_var in the outer func wasn't changed because the anonymous inner function hadn't been called yet.

// Closures: don't mutate outer vars, instead redefine them!
func outer() (func() int, int) {
	outer_var := 2 // NOTE outer_var is outside inner's scope
	inner := func() int {
		outer_var += 99  // attempt to mutate outer_var
		return outer_var // => 101 (but outer_var is a newly redefined
		//  variable visible only inside inner)
	}
	return inner, outer_var // => 101, 2 (still!)
}

I saw you made updates on the README file, but some people may also read your pdf file.

@rajuvai12
Copy link

Nony yet

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

2 participants