[swift-evolution] [Proposal] Union Type
jgroff at apple.com
Fri Jul 1 12:03:17 CDT 2016
> On Jul 1, 2016, at 2:08 AM, Cao Jiannan via swift-evolution <swift-evolution at swift.org> wrote:
> Hi all,
> I'm now officially proposal the union type feature for Swift. Please see:
> Add union type grammar, represents the type which is one of other types.
> var stringOrURL: String | URL = "https://www.apple.com"
> I would be thankful if someone support this idea and give some advice. Thanks!
We touch on this in the "commonly proposed" list:
Disjunctions (logical ORs) in type constraints <https://lists.swift.org/pipermail/swift-evolution-announce/2016-June/000182.html>: These include anonymous union-like types (e.g. (Int | String) for a type that can be inhabited by either an integer or a string). "[This type of constraint is] something that the type system cannot and should not support."
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution