具有长参数的 IntRange
IntRange with long parameters
我正在研究 Android 支持库中的 IntRange
实现,我注意到 from
和 to
参数都是 long 类型,默认情况下它们使用长最大值和最小值。
这里有官方文档供参考:https://developer.android.com/reference/android/support/annotation/IntRange.html#from()
我的问题是,如果它定义了 int
范围,为什么它是 long
,为什么它是必需的或有用的?
Denotes that the annotated element should be an int or long in the given range
在文档中指出,带注释的元素应该是 int 或 long,所以我想这是为了避免为 LongRange
.
创建单独的 class
并且由于 long 值可以远远超过 int 值,因此 IntRange.from()
和 IntRange.to()
应该是 Long
类型
我正在研究 Android 支持库中的 IntRange
实现,我注意到 from
和 to
参数都是 long 类型,默认情况下它们使用长最大值和最小值。
这里有官方文档供参考:https://developer.android.com/reference/android/support/annotation/IntRange.html#from()
我的问题是,如果它定义了 int
范围,为什么它是 long
,为什么它是必需的或有用的?
Denotes that the annotated element should be an int or long in the given range
在文档中指出,带注释的元素应该是 int 或 long,所以我想这是为了避免为 LongRange
.
并且由于 long 值可以远远超过 int 值,因此 IntRange.from()
和 IntRange.to()
应该是 Long