In Swift 3, I wonder why I can use the semi-open range operator ..<
in Data.subdata (in :) , but not the closed range operator ...
I searched everywhere, but I canβt understand why this gives me this error: No candidates β...β create the expected context result type 'Range' (aka 'Range')
Here is an example of one that works, and one that does not work:
import Foundation let x = Data(bytes: [0x0, 0x1]) let y : UInt8 = x.subdata(in: 0..<2).withUnsafeBytes{$0.pointee} let z : UInt8 = x.subdata(in: 0...1).withUnsafeBytes{$0.pointee} // This fails
Thanks!
source share