16 lines
341 B
Go
16 lines
341 B
Go
package util
|
||
|
||
type Number interface {
|
||
~int | ~int8 | ~int16 | ~int32 | int64 |
|
||
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr |
|
||
~float32 | ~float64
|
||
}
|
||
|
||
// IsBetween n是否在a、b之间(等于也算)
|
||
func IsBetween[T Number](n T, a T, b T) bool {
|
||
if (n > a && n > b) || (n < a && n < b) {
|
||
return false
|
||
}
|
||
return true
|
||
}
|