package
Version:
v0.0.9
Opens a new window with list of versions in this module.
Published: May 15, 2026
License: Apache-2.0
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
operator
三元表达式辅助函数。
基础用法
name := operatorpkg.Ternary(ok, "yes", "no")
注意事项
只适合简单值选择;复杂分支使用普通 if 更清晰。
验证
go test ./operator
Documentation
¶
func Ternary[T any](cond bool, v1 T, v2 T) T
Ternary 三元表达式 = cond ? v1 : v2
Source Files
¶
Click to show internal directories.
Click to hide internal directories.