I've run into an issue with my enums in that I want to initialize a case to the double value of PI / 180
. Is there a way to take this calculated value via a constant or some funky magic and turn it into a literal so that I can initialize the enum?
I would prefer not to have to do a 3.14....
- I would rather use the actual compiler and hardware computed representation of this value.
So my 1st attempt was:
public enum ANGLE_TYPE : Double {
case DEGREES = Double(CGFloat(M_PI / 180.0))
case RADIANS = 1.0
}
I keep getting the error Raw value for enum case must be a literal
Second attempt was :
public enum ANGLE_TYPE : Double {
let d : Double = Double(CGFloat(M_PI / 180.0))
case DEGRESS = d
}
and i get the same error.
Could somebody please tell me how to go about doing this.