let animal = "start"
let firstLetterIndex = animal.index(animal.startIndex, offsetBy: 3)
print(animal[animal.startIndex])
print(animal[firstLetterIndex])
print(animal[..<firstLetterIndex])
// 打印结果 animal[animal.startIndex]为"s",animal[firstLetterIndex]为"r", animal[..<firstLetterIndex]为"sta"
// animalkey为String.SubSequence类型
let animalKey = animal[..<firstLetterIndex]
// animalkeyString为String类型
let animalKeyString = String(animalKey)
// animal[animal.startIndex]为"s",animal[firstLetterIndex]为"r"
// 当 animalsDict[animalKeyString] 为 nil时,presetValue默认值为 ["aaaaa"]
var presetValue = animalsDict[animalKeyString] ?? ["aaaaa"]
print(presetValue)
// ["aaaaa"]
打印结果如上所示