[swift-evolution] [pitch] Variadic Arguments should accept Arrays
Tino Heth
2th at gmx.de
Sat Mar 11 03:47:01 CST 2017
>>> foo(["a", "b", "c"] as String...)
>>
>> I like this
>
> +1
I really don't get this:
We have methods like NSLayoutConstraint.activate(_ constraints: [NSLayoutConstraint]), which works with an array, declares its parameter to be array and is called with an array. Quite simple.
On the other hand, we have functions which work with an array, but are declared with Type…, and are called with a comma-separated list of elements — and we should add an option to call this function (which works on array!) with an array that is decorated with a strange cast?
That looks extremely awkward to me.
Can I declare a variable like
var list: String… = "a"
?
Imho it's better to get rid of these odd types completely.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170311/5ffb9eab/attachment.html>
More information about the swift-evolution
mailing list