From f3b514a3763d2f5127e2a36cfdb662c6eb4924ac Mon Sep 17 00:00:00 2001 From: Kurt Jung Date: Fri, 23 Aug 2013 11:50:17 -0400 Subject: =?UTF-8?q?Added=20clipping=20support=20adapted=20from=20script=20?= =?UTF-8?q?by=20Andreas=20W=C3=BCrmser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'util.go') 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 + } +} -- cgit v1.2.1-24-ge1ad