1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

refactor: change TernaryOperator signature

This commit is contained in:
dudaodong
2022-08-29 11:27:51 +08:00
parent c695837b16
commit 6d6c3f692f
3 changed files with 8 additions and 8 deletions

View File

@@ -67,11 +67,11 @@ func Nand[T, U any](a T, b U) bool {
return !Bool(a) || !Bool(b)
}
// TernaryOperator if true return trueValue else return falseValue
func TernaryOperator[T any](isTrue bool, trueValue T, falseValue T) T {
if isTrue {
return trueValue
// TernaryOperator checks the value of param `isTrue`, if true return ifValue else return elseValue
func TernaryOperator[T, U any](isTrue T, ifValue U, elseValue U) U {
if Bool(isTrue) {
return ifValue
} else {
return falseValue
return elseValue
}
}