Re:Apple’s use of Swift in iOS 12
by jchb on Friday September 28, 2018 @09:27AM
(#18093115)
> when Optional values start brushing up against that top level of user-visible stuff
Perhaps you are under-using sum types - or enums with associated values as they are called in Swift.
Difficult to get into details in this format, but for example, instead of:
`enum State {
case connected(Connection, SomeOtherStateRelatedToConnected)
case disconnected
}
let state: State
`
You have:
`
var connection: Connection?
var someOtherState: SomeOtherStateRelatedToConnected?
`
Perhaps you are under-using sum types - or enums with associated values as they are called in Swift. Difficult to get into details in this format, but for example, instead of:
`enum State { case connected(Connection, SomeOtherStateRelatedToConnected) case disconnected }
let state: State `
You have: ` var connection: Connection? var someOtherState: SomeOtherStateRelatedToConnected? `