[swift-evolution] [Pitch?] Way to declare a Swift Array that guarantees it can't be empty

Tino Heth 2th at gmx.de
Tue Aug 8 07:20:04 CDT 2017

> Fixed-size arrays do not solve this particular issue that I've noted above.
And I didn't say so ;-)
But generic value parameters would not only allow you to define fixed-size arrays, but also arrays with certain other properties:
Minimal size, maximal size… maybe even number of elements or other more complicated things.
(that is one reason why I think this is the best approach — its more versatile than the alternative)

I really hope that you find supporters for non-empty arrays - that would also be a strong motivation to add subtyping for arrays ;-) (struct NonEmptyArray: Array)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170808/dec49d87/attachment.html>

More information about the swift-evolution mailing list