【发布时间】:2015-09-21 16:22:33
【问题描述】:
尝试在带有枚举的 switch case 中调用 count() 函数时出现一个我无法解释的错误:
enum Token{
case Name(String)
var count:Int{
switch self{
case .Name(let string):
return count(string)
}
}
}
错误是Cannot invoke 'count' with an argument list of type '((String))'。
我也试过
case .Name(let string):
return string.characters.count
出现错误'String' does not have a member named 'characters'。
有人知道我做错了什么吗?
【问题讨论】:
标签: ios swift enums pattern-matching