3 ms·
Doesn't exactly win any awards for elegance, but: err := h(map[bool]func(T){true: f, false: g}[cond(x)](x)) You're probably not going to want to use this th
by Beltalowda 5y ago
Doesn't exactly win any awards for elegance, but:
err := h(map[bool]func(T){true: f, false: g}[cond(x)](x))
You're probably not going to want to use this though, although I've used the map[bool]T trick in some simpler examples.