I have an Array[Byte] and I want to convert it to an Array[Int]:
for example,
val x : Array[Byte] = Array(192.toByte, 168.toByte, 1.toByte, 9.toByte)
val y : Array[Int] = Array(192, 168, 1, 9)
How can I convert x to y ?
I tried this and it works:
val y = x.map(_.toInt & 0xff).deep
IndexedSeq[Any] Can you please explian those & 0xff and .deep. Arwa Z?val y = x.map(_.toInt) it returns I@50930bff, and when I do val y = x.map(_.toInt).deep it returns Array(-64, -88, 1, 9). That is why I add & 0xff so the result is Array(192, 168, 1, 9).