From 1d95731b71660978d0efe36f768969852b585ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=82=B3=E6=98=8E?= Date: Mon, 25 May 2020 17:39:04 +0800 Subject: [PATCH] =?UTF-8?q?Update=EF=BC=9A=E8=A1=A5=E5=85=85=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/c01/c01_10.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/c01/c01_10.md b/source/c01/c01_10.md index 85dab1f..39465d6 100644 --- a/source/c01/c01_10.md +++ b/source/c01/c01_10.md @@ -164,6 +164,27 @@ hello, python hello, go ``` +如果你用一个变量来接收的话,接收到的是索引 + +```go +import "fmt" + +func main() { + myarr := [...]string{"world", "python", "go"} + for i := range myarr { + fmt.Printf("hello, %v\n", i) + } +} +``` + +输出如下 + +``` +hello, 0 +hello, 1 +hello, 2 +``` + --- -- GitLab