I'm trying to use enum in my project like this:
enum ShipShift: CGFloat {
case Forward = 1
case Stop = 0
case Back = -1.0
}
but the Xcode throw an error on the third case
as
Raw value for enum case must be a literal
then I change my code into:
enum ShipShift: CGFloat {
case Forward = 1
case Stop = 0
case Back = -1
}
and Xcode is happy.
But I don't know the real reason. Why the enum cannot have a case which raw value is a negative decimal?
What should I do if I want the Back
case equal to -0.5
?