✨Feat: 函数声明语法糖
This commit is contained in:
@@ -9,7 +9,12 @@ func add(x int, y int) int {
|
|||||||
return x + y
|
return x + y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func add2(x, y int) int {
|
||||||
|
return x + y
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("You know Pi =", math.Pi)
|
fmt.Println("You know Pi =", math.Pi)
|
||||||
fmt.Println("And You know 1+2 =", add(1, 2))
|
fmt.Println("And You know 1+2 =", add(1, 2))
|
||||||
|
fmt.Println("And You know 1+2 =", add2(1, 2), "Using syntax sugar")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user