在文档中,我们有:
请注意,数字的装箱不保留标识
但下面的示例给出了不同的结果。
val number1 = 127
val b1 : Int? = number1
val b2 : Int? = number1
print(b1 === b2) // this prints true
val number2 = 128
val c1 : Int? = number2
val c2 : Int? = number2
print(c1 === c2) // this prints false
在大于127的数字中,它可以正常工作,但当数字大于128(8位)时,为什么会出现问题?