I was first trying out a blank number type with:
struct Test1 {}
extension Test1: AdditiveArithmetic {
static let zero = Test1()
//...
}
Then I wondered if I could the same thing with a single-state enum:
enumTest2 { case zero }
I tried adding AdditiveArithmetic
conformance, but it turns out that Xcode 10.3 insisted that I add a static
member to satisfy the zero
static property. Of course, doing that creates an error that the property clashes with the case. But pulling back, it seems that it should work directly; .zero
is the name of a value of type Test2
, just like we can play around between cases and type-static names when making an OptionSet
.
The version of Xcode 11 beta 6 crashes every time I try to use it, so I have no idea what its version of Swift does.