Can someone explain why half open and closed ranges no longer work the same on strings in Swift 3?
This code works:
var hello = "hello"
let start = hello.index(hello.startIndex, offsetBy: 1)
let end = hello.index(hello.startIndex, offsetBy: 4)
let range = start..<end // <-- Half Open Range Operator still works
let ell = hello.substring(with: range)
But this does not:
var hello = "hello"
let start = hello.index(hello.startIndex, offsetBy: 1)
let end = hello.index(hello.startIndex, offsetBy: 4)
let range = start...end // <-- Closed Range Operator does NOT work
let ello = hello.substring(with: range) // ERROR
It results in an error like the following:
Cannot convert value of type 'ClosedRange<String.Index>' (aka 'ClosedRange<String.CharacterView.Index>') to expected argument type 'Range<String.Index>' (aka 'Range<String.CharacterView.Index>')