let array = [Int]() _ = array.index(before: array.endIndex) // <=== is -1 let s = "" _ = s.index(before: endIndex) // crash
I tried all combinations of
index(after:): Array return invalid values, while String crash. What the reason for this inconsistency? Is it because they want Array to be fast and do no error check at all and simply do the math and return whatever?
Shouldn't they both crash? Maybe crash in debug mode and disable error check and return invalid result in non-debug mode?