I'm slicing an array of strings and setting that to a [String]
variable, but the type checker is complaining. Is it a possible compiler bug?
var tags = ["this", "is", "cool"] tags[1..<3] var someTags: [String] = tags[1..<3]
Subscripting an array with a range doesn't return an array, but a slice. You can create an array out of that slice though.
var tags = ["this", "is", "cool"] tags[1..<3] var someTags: Slice<String> = tags[1..<3] var someTagsArray: [String] = Array(someTags)
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