A
A
Aleksandr Govorukhin2017-11-11 19:34:01
Swift
Aleksandr Govorukhin, 2017-11-11 19:34:01

'subscript' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion of Swift 4?

there is a string str = "asdlkmaskdnasljkvakjsndfasdf"

for i in 2..<str.count {
      print(str[i])
}

I get the error "'subscript' is unavailable: cannot subscript String with an Int, see the documentation comment for discussion"
What's the problem? What am I doing forbidden?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksandr Govorukhin, 2017-11-11
@SnapSh0t

String(Array(stringToIndex)[index])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question