> On 19. Jun 2017, at 04:30, Nevin Brackett-Rozinsky via swift-users
> wrote:
>
> Is there a way to restrict the associated values of an enum? For example,
> suppose I have this type:
>
> enum Angle {
> case radians(Double)
> case degrees(Double)
> }
>
> I want to ensure that the rad
> On 19. Jun 2017, at 20:03, Karl Wagner wrote:
>
>
>> On 19. Jun 2017, at 04:30, Nevin Brackett-Rozinsky via swift-users
>> mailto:swift-users@swift.org>> wrote:
>>
>> Is there a way to restrict the associated values of an enum? For example,
>> suppose I have this type:
>>
>> enum Angle {
> On Jun 18, 2017, at 10:33 PM, Howard Lovatt via swift-users
> wrote:
>
> To me Angle is a unit with two common representations: radians and degrees.
> It's not an enum because it doesn't have two values, it has one value that
> you can view in two ways.
>
> Therefore I would make an Angle
To me Angle is a unit with two common representations: radians and degrees.
It's not an enum because it doesn't have two values, it has one value that
you can view in two ways.
Therefore I would make an Angle struct, something like:
//: Angle struct instead of angle enum
import Foundation
str
> On Jun 18, 2017, at 19:30, Nevin Brackett-Rozinsky via swift-users
> wrote:
>
> Is there a way to restrict the associated values of an enum? For example,
> suppose I have this type:
>
> enum Angle {
> case radians(Double)
> case degrees(Double)
> }
>
> I want to ensure that the rad
Is there a way to restrict the associated values of an enum? For example,
suppose I have this type:
enum Angle {
case radians(Double)
case degrees(Double)
}
I want to ensure that the radians values is always in [0, 2π) and the
degrees values is always in [0, 360). Ideally I would like to