[swift-evolution] Allowing enum extensions to also be able to expand case options

Daniel Duan daniel at duan.org
Thu Jun 30 19:09:45 CDT 2016


Edward Valentini via swift-evolution <swift-evolution at ...> writes:

-1. Having a proper sum type so that the compiler can verify all cases are
covered is important.  If you need a type of extensible tagged value,
I recommend using static members:

struct MyDirection {
    static let east = MyDirection()
    static let west = MyDirection()
}

extension MyDirection {
    static let north = MyDirection()
    static let south = MyDirection()
}

Sum type: https://en.wikipedia.org/wiki/Tagged_union




More information about the swift-evolution mailing list