[swift-evolution] Proposal: An Either Type in the STL

Thorsten Seitz tseitz42 at icloud.com
Sat Dec 12 12:58:30 CST 2015

> Am 12.12.2015 um 19:01 schrieb Joe Groff via swift-evolution <swift-evolution at swift.org>:
> (T | T | U | V) and (U | T | V) would be distinct types

That would be unexpected. I’d expect them to be the same type.

In Ceylon I can do the following without problems:
String|String|Integer foo = 1;
Integer|String bar = foo;
interface Parent {}
interface ChildA satisfies Parent {}
interface ChildB satisfies Parent {}
ChildA a = childA();
ChildB b = childB();
Parent p1 = a;
ChildA|Parent p2 = b;
Parent p3 = if (x) then a else b;
Everything fits nicely as expected.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151212/07a7dada/attachment.html>

More information about the swift-evolution mailing list