From c3f6ea754a1df6668d6cd077637b321738020bcc Mon Sep 17 00:00:00 2001 From: fechin Date: Thu, 24 Nov 2022 15:06:48 +0800 Subject: [PATCH] "Function literals" is better than "Anonymous function" --- source/_posts/golang.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/_posts/golang.md b/source/_posts/golang.md index 75486ae..2993997 100644 --- a/source/_posts/golang.md +++ b/source/_posts/golang.md @@ -587,14 +587,15 @@ fmt.Println(a) // => 3 fmt.Println(b) // => 7 ``` -### Anonymous function +### Function literals + ```go r1, r2 := func() (string, string) { - x := []string{"hello", "world"} + x := []string{"hello", "quickref.me"} return x[0], x[1] }() -// => hello world +// => hello quickref.me fmt.Println(r1, r2) ```