Byte
is immutable, which means its value cannot be changed. Assigning to it won't work in your case, since that would simply rebind the reference (which won't propagate back to the caller).
You could use MutableByte
, a one-element byte
/Byte
array, or a custom class.