2022-10-27 16:48:26 +02:00
|
|
|
package langext
|
|
|
|
|
|
|
|
func FormatBool(v bool, strTrue string, strFalse string) string {
|
|
|
|
if v {
|
|
|
|
return strTrue
|
|
|
|
} else {
|
|
|
|
return strFalse
|
|
|
|
}
|
|
|
|
}
|
2022-11-19 16:58:18 +01:00
|
|
|
|
|
|
|
func Conditional[T any](v bool, resTrue T, resFalse T) T {
|
|
|
|
if v {
|
|
|
|
return resTrue
|
|
|
|
} else {
|
|
|
|
return resFalse
|
|
|
|
}
|
|
|
|
}
|
2023-01-13 16:05:39 +01:00
|
|
|
|
|
|
|
func ConditionalFn00[T any](v bool, resTrue T, resFalse T) T {
|
|
|
|
if v {
|
|
|
|
return resTrue
|
|
|
|
} else {
|
|
|
|
return resFalse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ConditionalFn10[T any](v bool, resTrue func() T, resFalse T) T {
|
|
|
|
if v {
|
|
|
|
return resTrue()
|
|
|
|
} else {
|
|
|
|
return resFalse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ConditionalFn01[T any](v bool, resTrue T, resFalse func() T) T {
|
|
|
|
if v {
|
|
|
|
return resTrue
|
|
|
|
} else {
|
|
|
|
return resFalse()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ConditionalFn11[T any](v bool, resTrue func() T, resFalse func() T) T {
|
|
|
|
if v {
|
|
|
|
return resTrue()
|
|
|
|
} else {
|
|
|
|
return resFalse()
|
|
|
|
}
|
|
|
|
}
|