|
@@ -59,14 +59,29 @@ func main() {
|
|
|
// fmt.Printf("%d,%d", x, y)
|
|
|
}
|
|
|
{
|
|
|
- //匿名函数
|
|
|
- x, y := func() (int, int) {
|
|
|
- print("hello")
|
|
|
- return 3, 5
|
|
|
- }()
|
|
|
- func() {
|
|
|
- println("hello")
|
|
|
- }()
|
|
|
- fmt.Printf("%d,%d", x, y)
|
|
|
+ // //匿名函数
|
|
|
+ // x, y := 1, 2
|
|
|
+ // a, b := func(x, y int) (int, int) {
|
|
|
+ // x = 4
|
|
|
+ // print(x + y)
|
|
|
+ // return x, y
|
|
|
+ // }(x, y)
|
|
|
+ // func() {
|
|
|
+ // println("hello")
|
|
|
+ // }()
|
|
|
+ // fmt.Printf("%d,%d", a, b)
|
|
|
+ // //在函数体后面跟上()表示声明后立即执行
|
|
|
+
|
|
|
+ }
|
|
|
+ {
|
|
|
+ x, y := "炸", "煎鱼"
|
|
|
+ fmt.Println(&x)
|
|
|
+ _, _ = func(x, y string) (s string, err error) {
|
|
|
+ x = "吃"
|
|
|
+ fmt.Println(&x)
|
|
|
+ return x + y, nil
|
|
|
+ }(x, y)
|
|
|
+ fmt.Println(&x)
|
|
|
+ fmt.Println(x, y)
|
|
|
}
|
|
|
}
|