3 ms·
if a > b { // use a } else { // use b }
by insertnickname 11y ago
if a > b {
// use a
} else {
// use b
}
- ridiculous_fish 11y agoOh dear. You had one job, min!
- insertnickname 11y agoYeah, I was thinking of max, not min, sorry. My point was that it's a trivial thing to write, your generic max (or min) is right there. The math.Max() (and math.Min()) function is not trivial, it handles certain special cases, and that's probably why it was included.[1] [1] https://golang.org/pkg/math/#Max https://golang.org/pkg/math/#Max
- Veedrac 11y agoThat's actually the wrong way around.
- insertnickname 11y agoYeah, I was thinking of max, not min, sorry. My point was that it's a trivial thing to write, your generic max (or min) is right there. The math.Max() (and math.Min()) function is not trivial, it handles certain special cases, and that's probably why it was included.[1] [1] https://golang.org/pkg/math/#Max https://golang.org/pkg/math/#Max