mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:55:35 +08:00
添加06.2.md和相关的例子与问题解答
This commit is contained in:
17
eBook/examples/chapter_6/side_effect.go
Normal file
17
eBook/examples/chapter_6/side_effect.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// this function changes reply:
|
||||
func Multiply(a, b int, reply *int) {
|
||||
*reply = a * b
|
||||
}
|
||||
|
||||
func main() {
|
||||
n := 0
|
||||
reply := &n
|
||||
Multiply(10, 5, reply)
|
||||
fmt.Println("Multiply:", *reply) // Multiply: 50
|
||||
}
|
Reference in New Issue
Block a user