go 指针

package main

import "fmt"

func f(s *string) (string, string) {
	*s = "def"
	return "hello", *s
}

func main() {
	s := "abc"
	a, b := f(&s)
	fmt.Println(a, b)
}

hello def

猜你喜欢

转载自xiangjie88.iteye.com/blog/2383772