1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00
Files
lancet/common/common.go
郑一诺她爸 72e1d92fa1 TernaryOperator Reduce if else operations (#56)
* feat:(slice add AppendIfAbsent function)

* feat:(slice add TernaryOperator function)

Co-authored-by: george.zheng <george.zheng@ambergroup.io>
2022-08-27 19:12:03 +08:00

11 lines
222 B
Go

package common
// TernaryOperator if true return trueValue else return falseValue
func TernaryOperator[T any](isTrue bool, trueValue T, falseValue T) T {
if isTrue {
return trueValue
} else {
return falseValue
}
}