Hey, at what point is the value converted to Int in Kotlin? AS is showing a warning that Byte is expected but found Int even though in the Java version of the code it is picked up as byte.
Kotlin:
var r = byteArray[3 + i]
If (r > 0) r += 255 //the warning is shown here
Java:
byte r = byteArray[3 + i]
If (r > 0) r += 255; //the warning is not shown
g
gildor
11/01/2019, 2:56 AM
It’s correct. Kotlin is designed to be explicit for such implcit type convertations
a
Anastasia Finogenova
11/01/2019, 3:00 AM
I think I got it, thanks
s
Stephan Schroeder
11/01/2019, 4:57 PM
and the way to be explicit about it is to cal
r.toInt()
. But you use the += operator, so you would need to reasign. So better start of with an int.