[swift-evolution] [Proposal] Union Type

Joe Groff 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:
> 
> 
> https://github.com/frogcjn/swift-evolution/blob/master/proposals/xxxx-union-type.md
> Introduction
> 
> 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:

https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md

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."


-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160701/fbb9497b/attachment.html>


More information about the swift-evolution mailing list