"Function literals" is better than "Anonymous function"

This commit is contained in:
fechin committed 2022-11-24 15:06:48 +08:00
1 parent 5cd6d91f5c
commit c3f6ea754a
1 file changed
+4 -3
+4 -3
View File
@@ -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)
```