A String
is not a sequence, you need to call the characters
property to get a sequence
.
let a = "what is this"
for b in a.characters {
print(b, terminator: "")
}
// "what is this"
You have to use the characters
member variable of String
if you want to enumerate all the characters.
let a = "what is this"
for b in a.characters
{
print(b)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.