github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/base/bternaryexpr/README.md (about) 1 # ternary 2 3 ## API 4 5 - TernaryExpr 6 7 ```go 8 TernaryExpr[T any](boolExpr bool, trueReturn T, falseReturn T) T 9 ``` 10 11 ## EXAMPLE 12 13 ```go 14 package main 15 16 import ( 17 "fmt" 18 "github.com/songzhibin97/go-baseutils/base/bternaryexpr" 19 ) 20 21 func main() { 22 fmt.Println(bternaryexpr.TernaryExpr(true, 1, 2)) // 1 23 fmt.Println(bternaryexpr.TernaryExpr(false, 1, 2)) // 2 24 } 25 ```