golang-cheat-sheet icon indicating copy to clipboard operation
golang-cheat-sheet copied to clipboard

Update your golang_refcard.pdf, please

Open appak21 opened this issue 2 years ago • 1 comments

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.

appak21 avatar Oct 22 '22 09:10 appak21

Nony yet

rajuvai12 avatar Jan 21 '23 05:01 rajuvai12