[swift-evolution] [pitch] Variadic Arguments should accept Arrays
Derrick Ho
wh1pch81n at gmail.com
Sat Mar 11 09:39:19 CST 2017
I'd find it fantastic if they added
var list: String... = 1, 2,3,4,5
However if they remove Variadic arguments then apple would need to remove
it from their apis. To name a few...
print
NSPredicate(format:)
UIAlertView
Removing variadic arguments would be a breaking change though. They would
either need to remove it quickly or deprecate all the methods that use
variadic arguments. Might take awhile before it is removed completely.
On Sat, Mar 11, 2017 at 4:47 AM Tino Heth via swift-evolution <
swift-evolution at swift.org> wrote:
> 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.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170311/ceab7bfa/attachment.html>
More information about the swift-evolution
mailing list