summaryrefslogtreecommitdiffhomepage
path: root/control/controlhttp/controlhttpserver/controlhttpserver.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2024-12-11 10:55:33 -0800
committerGitHub <noreply@github.com>2024-12-11 10:55:33 -0800
commitc9188d7760fb68a60e6791f0adf42f8dc1728251 (patch)
treebaf390d585dcf9f1244a974729030943284490e2 /control/controlhttp/controlhttpserver/controlhttpserver.go
parent00458600605e8db25655f9abb95cac5bb78b3c55 (diff)
downloadtailscale-c9188d7760fb68a60e6791f0adf42f8dc1728251.tar.xz
tailscale-c9188d7760fb68a60e6791f0adf42f8dc1728251.zip
types/bools: add IfElse (#14272)
The IfElse function is equivalent to the ternary (c ? a : b) operator in many other languages like C. Unfortunately, this function cannot perform short-circuit evaluation like in many other languages, but this is a restriction that's not much different than the pre-existing cmp.Or function. The argument against ternary operators in Go is that nested ternary operators become unreadable (e.g., (c1 ? (c2 ? a : b) : (c2 ? x : y))). But a single layer of ternary expressions can sometimes make code much more readable. Having the bools.IfElse function gives code authors the ability to decide whether use of this is more readable or not. Obviously, code authors will need to be judicious about their use of this helper function. Readability is more of an art than a science. Updates #cleanup Signed-off-by: Joe Tsai <joetsai@digital-static.net>
Diffstat (limited to 'control/controlhttp/controlhttpserver/controlhttpserver.go')
0 files changed, 0 insertions, 0 deletions