Why are String offsets so complicated?

just saying, the upcoming Integer-convertible character literals proposal should make a lot of these problems moot. Usually when you want to get the nth character in a string, it's a specially formatted ASCII string like MM/DD/YYYY which are much better represented as [UInt8] (or even a tuple or fixed size array, if we ever get those) instead of String. Then you could write things like

if datestring[6 ..< 10] == ['1', '9', '8', '9'] 
{
    print("i was born in 1989!")
}
4 Likes