diesieben07
07/24/2017, 9:26 AMtechie01
07/24/2017, 9:27 AMtechie01
07/24/2017, 9:27 AMdiesieben07
07/24/2017, 9:28 AMdiesieben07
07/24/2017, 9:29 AMtechie01
07/24/2017, 9:29 AMdiesieben07
07/24/2017, 9:29 AMdiesieben07
07/24/2017, 9:30 AMtechie01
07/24/2017, 9:30 AMdiesieben07
07/24/2017, 9:31 AMdiesieben07
07/24/2017, 9:31 AMkingsley
07/24/2017, 9:32 AMval a: Int? = 20
doesn’t use Integer(20)
, but rather Integer.valueOf(20)
.
Like @diesieben07 said, this function returns cached objects within a defined range, hence the equality passes. But you shouldn’t rely on this behaviortechie01
07/24/2017, 9:35 AMdiesieben07
07/24/2017, 9:35 AMegoscio
07/24/2017, 9:36 AMegoscio
07/24/2017, 9:37 AMegoscio
07/24/2017, 9:37 AMtechie01
07/24/2017, 9:37 AMshruggie
07/24/2017, 11:37 AMshruggie
07/24/2017, 11:38 AMshruggie
07/24/2017, 11:39 AMbaermitumlaut
07/24/2017, 7:26 PMmap[arg]
Int?
and not Int
here?
fun main(args: Array<String>) {
val map = mutableMapOf<String, Int>()
val lst = mutableListOf<Int>()
map["answer"] = 42
for (arg in args) {
if (arg in map) {
lst.add(map[arg])
}
}
}
I think this should compile just fine, but it doesn't.damian
07/24/2017, 7:27 PMnull
if the key is not foundbaermitumlaut
07/24/2017, 7:27 PMarg in map
just before, so the key exists.damian
07/24/2017, 7:28 PMdamian
07/24/2017, 7:29 PMmap[arg]!!
baermitumlaut
07/24/2017, 7:31 PM<String, Int>
and not <String, Int?>
, and far as I understood it, this implementation by Kotlin should then also guarantee that get never returns null? Not the case then I guess?baermitumlaut
07/24/2017, 7:32 PMapyrael
07/24/2017, 7:33 PMapyrael
07/24/2017, 7:33 PM