Hello,
I wrote a code to get second character of the string as follows:
print("name:")
let name = readLine()!
print("Age:")
let age = Int(readLine()!)!
print("Name:\(name), Age:\(age)")
let idx = name.index(name.startIndex, offsetBy: 1)
print(name[idx])
print(idx)
I entered these to test this code;
name: John
age:20
I expected result: name:John
age:20 o
1
but I got:
name:John
age:20
o
Index(_rawBits: 65799)//I expected 1
If someone can explain why I can't get index number of the string, I'd be very appreciated.
thanks for your answer in advance.
c00012