How do you initialize an empty ByteArray in Kotlin? Whenever I try to do this:
val asdfasdf : ByteArray
I get told that I need to initialize asdfasdf when I try to use it later here:
mVisualizer.getWaveForm(asdfasdf)
Variable 'asdfasdf' must be initialized
The easiest way to make a ByteArray in Kotlin in my opinion is to use byteArrayOf(). It works for an empty ByteArray, as well as one which you already know the contents of.
val nonEmpty = byteArrayOf(0x01, 0x02, 0x03)
var empty = byteArrayOf()
empty += nonEmpty
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With