3 Commits
Author SHA1 Message Date
wonder 15539ea817 ✨Feat: 多返回值函数 2025-12-29 16:11:18 +08:00
wonder bf75705fd6 ✨Feat: 函数声明语法糖 2025-12-29 16:07:24 +08:00
wonder 1f8e8e006e ✨Feat: 函数声明 2025-12-29 16:02:42 +08:00
+16
View File
@@ -5,6 +5,22 @@ import (
"math"
)
func add(x int, y int) int {
return x + y
}
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)
}