12
使用在有條件的價值假設中去,我們有一個函數返回兩個參數Golang:從函數返回多個參數
func squareAndCube(int side) (square int, cube int) {
square = side * side
cube = square * side
return
}
然後你想使用該功能的第一(第二)值的條件:
square, _ := squareAndCube(n)
if square > m {
...
}
然而,我們可以做一個行頭兩行,如果我們不需要價值廣場其他地方使用?例如。
if squareAndCube(n).First() > m {
...
}