gpt4 book ai didi

Swift 编译错误 : 'case' label can only appear inside a 'switch' statement?

转载 作者:行者123 更新时间:2023-11-28 11:49:42 31 4
gpt4 key购买 nike

我有一个简单的代码:

enum Coin {
case heads: 0
case tails
}

它在第 2 行抛出一个错误

error: 'case' label can only appear inside a 'switch' statement

如何解决?

最佳答案

试试这个:

enum Coin: Int {
case heads = 0
case tails
}

关于Swift 编译错误 : 'case' label can only appear inside a 'switch' statement?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51998825/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com