[swift-evolution] Bool vs. Optional<Void>

Brent Royal-Gordon brent at architechies.com
Thu Dec 17 04:25:20 CST 2015


This is less a proposal and more a vague notion, but here goes.

Occasionally, Optional<Void> comes up in Swift. This particularly happens with optional chaining (and its socially awkward twin `Optional.flatMap(_:)`), but I occasionally see it come up in other places, particularly where you’re using a Result-ish type. Wherever it does come up, it seems to have the same semantic meaning as Bool, with `nil` meaning `false` and `()` meaning `true`.

Does it make sense to somehow unify them? Perhaps turn Bool into a typealias for Optional<Void> and move all of its conformances into (not yet supported) conditional conformances on Optional?

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list