GO 三元表达式、三目运算
package main
import "fmt"
func main() {
fmt.Println(If(2>3, "大于", false))
}
func If(condition bool, trueVal, falseVal interface{}) interface{} {
if condition {
return trueVal
}
return falseVal
}
package main
import "fmt"
func main() {
fmt.Println(If(2>3, "大于", false))
}
func If(condition bool, trueVal, falseVal interface{}) interface{} {
if condition {
return trueVal
}
return falseVal
}