summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.go b/util.go
index 5043601..b2202ca 100644
--- a/util.go
+++ b/util.go
@@ -202,3 +202,21 @@ func utf8toutf16(s string) string {
}
return string(res)
}
+
+// Return a if cnd is true, otherwise b
+func IntIf(cnd bool, a, b int) int {
+ if cnd {
+ return a
+ } else {
+ return b
+ }
+}
+
+// Return aStr if cnd is true, otherwise bStr
+func StrIf(cnd bool, aStr, bStr string) string {
+ if cnd {
+ return aStr
+ } else {
+ return bStr
+ }
+}