putInt8
fun ByteArray.putInt8(offset: Int, value: Int, validRange: IntRange = Byte.MIN_VALUE..Byte.MAX_VALUE)
Writes an Int8 value to the byte array at the specified offset.
This function takes an integer value and writes it as a single byte (Int8) into the byte array at the specified offset. It also validates that the value falls within a specified range, ensuring it can be represented as a single byte.
Parameters
offset
The offset (index) in the byte array where the Int8 value should be written. Must be within the valid range of the array's indices.
value
The Int8 value to be written.
validRange
The valid range for the value. Defaults to Byte.MIN_VALUE to Byte.MAX_VALUE (i.e., -128 to 127). Any value outside this range will cause an exception to be thrown.
Throws
If the value is outside the specified validRange.
If the offset is negative or greater than or equal to the array's size.