✨Feat: 多返回值函数

This commit is contained in:
2025-12-29 16:11:18 +08:00
parent bf75705fd6
commit 15539ea817
+6
View File
@@ -13,8 +13,14 @@ func add2(x, y int) int {
return x + y
}
func swap(x, y string) (string, string) {
return y, x
}
func main() {
fmt.Println("You know Pi =", math.Pi)
fmt.Println("And You know 1+2 =", add(1, 2))
fmt.Println("And You know 1+2 =", add2(1, 2), "Using syntax sugar")
a, b := swap("hello", "world")
fmt.Println("And You know swap('hello', 'world') =", a, b)
}