func readByte(bytes: [UInt8], offset: UInt8) -> UInt8 {
return bytes[offset] // Error: Cannot subscript a value of type '[UInt8]' with an index of type 'UInt8'
}
If you change the offset to any other Int will result in the same error. However if I use bytes[0] there is no problem. Probably because Swift knows what type to expect and converts the 0 accordingly. I am wondering what type that is.
offset: Intshould work.return bytes[Int(offset)]