Why doesn't Go have a math.Min / Max (int, int) function?

The Go language math package defines the min / max function, but only the float64 type, and there is no integer type min / max.

why?

Because go does not support overloading , it can only define a min / max function. So the official has only realized the most complex comparison of floating-point values, such as int, we have to implement it ourselves.

For details, please refer to this article .

Guess you like

Origin www.cnblogs.com/kkbill/p/12710639.html