为什么在命名 Swift 枚举大小写时出现 'is not a valid digit in integer literal' 错误?

Why am I getting 'is not a valid digit in integer literal' error while naming Swift enum case?

我正在尝试创建一个具有 运行 距离的枚举,但 Swift 不允许我以这种格式 5K 命名 enum 案例。我收到一条错误消息 'K' is not a valid digit in integer literal。这是我的代码:

标识符和类型 properties/enum 案例不能以数字开头。您需要更改枚举的命名约定。

enum RaceType: String {
    case fiveK = "5K"
    case tenK = "10K"
    case marathon
}

作为作弊,你可以使用 5 之类的表情符号或作为起始字母。