//functions swift
func countLetters(in string: String) {
print("The string \(string) has \(string.count) letters.")
}
countLetters(in: "Hello")
我不明白为什么它说计数不可用:没有普遍好的答案,请参阅文档评论进行讨论。
最佳答案
可能您的 Swift 版本太旧。 count
属性直到 Swift 4 才出现。在这种情况下,您可以使用 string.characters.count
来代替。
关于swift - 使用 Swift 函数计数进行黑客攻击不可用,没有普遍好的答案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51676071/