a8m / a8m/golang-cheat-sheet

Update your golang_refcard.pdf, please

未關閉 適合新手
#78 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
沒有語言資料
星號
8.8k
分支
1.1k
PR 合併指標
30 天內沒有已合併 PR

描述

outer_var in the outer func wasn't changed because the anonymous inner function hadn't been called yet.
```go
// 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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

The issue points to a discrepancy between the README and the PDF version of the cheat sheet. Locate the PDF file (likely named golang_refcard.pdf) in the repository, find the section on closures, and update the example to match the corrected version from the README. Verify the change by opening the PDF to ensure the example correctly shows that outer_var is not mutated until the inner function is called.

由索引模型根據 Issue 內容生成。

評估

領域
documentation
Issue 類型
文件
難度
1/5
預估耗時
1 小時以內
活躍度
停滯
描述清晰度
描述清楚
新手友好度
85/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。