Swift 4.2, String firstIndex() function error in Xcode playground

前端 未结 1 1880
甜味超标
甜味超标 2021-01-12 22:05

I was reading \"The Swift Programming Language Swift 4.2\" and in \"Strings and Characters\" chapter under \"Substrings\" section, the following code is given as an example:

相关标签:
1条回答
  • 2021-01-12 22:26

    You can try index(of

    let index = greeting.index(of: ",") ?? greeting.endIndex
    

    as firstIndex exists in Xcode 10 beta Doc

    0 讨论(0)
提交回复
热议问题