Kann jemand erklären, warum halb geöffnete und geschlossene Bereiche bei Swift 3 nicht mehr gleich funktionieren?Bereich Operatoren (.. <und ...) auf Swift Strings
Dieser Code funktioniert:
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)
Aber dies nicht:
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
Es führt zu einem Fehler wie folgt aus:
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>')