mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
"Function literals" is better than "Anonymous function"
This commit is contained in:
1 parent
5cd6d91f5c
commit
c3f6ea754a
1 file changed
+4
-3
@@ -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)
|
||||
```
|
||||
|
||||
|
||||
Reference in new issue
Block a user