mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2026-04-23 00:07:09 +08:00
20 lines
288 B
Go
20 lines
288 B
Go
package anyx
|
|
|
|
import "fmt"
|
|
|
|
func ExampleTernary() {
|
|
age := 15
|
|
res1 := Ternary(age < 18, "未成年", "成年")
|
|
res2 := Ternary(true, "Yes", "No")
|
|
res3 := Ternary(false, "Yes", "No")
|
|
|
|
fmt.Println(res1)
|
|
fmt.Println(res2)
|
|
fmt.Println(res3)
|
|
|
|
// Output:
|
|
// 未成年
|
|
// Yes
|
|
// No
|
|
}
|