MyBikeIsAwesome - 1 year ago 42

Swift Question

I am working with Doubles that have a range of

`0..<360`

`<..<`

`case 0:`

case 0<..<90:

case 90:

case 90<..<180:

case 180:

case 180<..<270:

case 270:

case 270<..<360:

I've looked into creating a custom infix operator that returns a

`Bool`

How can I accomplish this?

Answer Source

Your switch is unnecessarily complicated. See if this works for you:

```
let value: Double = 180
switch value {
case 0:
print("exactly 0")
case 0..<90:
print("less than 90")
case 90:
print("exactly 90")
case 90..<180:
print("less than 180")
case 180:
print("exactly 180")
case 180..<270:
print("less than 270")
case 270:
print("exactly 270")
default:
print("less than 360")
}
```