I have a simple code like:
enum Coin {
case heads: 0
case tails
}
It throws an error on Line 2 that
error: 'case' label can only appear inside a 'switch' statement
How do I solve it?
I have a simple code like:
enum Coin {
case heads: 0
case tails
}
It throws an error on Line 2 that
error: 'case' label can only appear inside a 'switch' statement
How do I solve it?
Try this:
enum Coin: Int {
case heads = 0
case tails
}
Whoops that was simple & I found the answer
First I did:
enum Coin {
case heads = 0
case tails
}
Just changed :
to =
but it threw error
Enum case cannot have a raw value if the enum does not have a raw type
So then I specified the type like:
enum Coin: Int {
case heads = 0
case tails
}
And voila it works