[英]type “string” doesn't conform to protocol “sequence”
String
不是序列,您需要调用characters
属性以获取sequence
。
let a = "what is this"
for b in a.characters {
print(b, terminator: "")
}
// "what is this"
如果要枚举所有字符,则必须使用String
的characters
成员变量。
let a = "what is this"
for b in a.characters
{
print(b)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.