How can I convert a ByteArray to an Int with Kotlin?
The code I was using in Java :
return ((buffer[offset++] & 0xff) << 24) |
((buffer[offset++] & 0xff) << 16) |
((buffer[offset++] & 0xff) << 8) |
(buffer[offset] & 0xff);
I tried this code in Kotlin :
return (buffer[offset++] and 0xff shl 24) or
(buffer[offset++] and 0xff shl 16) or
(buffer[offset++] and 0xff shl 8) or
(buffer[offset] and 0xff)
But it returns the following warning regarding the "and" operator :
None of the following candidates is applicable because of receiver type mismatch
