Skip to content

Update your golang_refcard.pdf, please #78

Open
@appak21

Description

@appak21

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions