mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 10:36:43 +00:00
10 lines
330 B
Go
10 lines
330 B
Go
package underscore
|
|
|
|
// Ternary returns the first argument if the condition is true, otherwise the second argument.
|
|
// Ternary is a special form of the if statement. It allows you to write code that is more concise and less verbose.
|
|
func Ternary[T any](condition bool, pos, neg T) T {
|
|
if condition {
|
|
return pos
|
|
}
|
|
return neg
|
|
}
|