In Scala, I can declare a byte array this way
val ipaddr: Array[Byte] = Array(192.toByte, 168.toByte, 1.toByte, 9.toByte)
This is too verbose. Is there a simpler way to declare a Byte array, similar to Java's
byte[] ipaddr = {192, 168, 1, 1};
Note that the following results in an error due to the .
in the String
InetAddress.getByAddress("192.168.1.1".toByte)
split
on aString
could do the trick:Breaking this down we have