<div dir="ltr">Well, I have found these discussions...<div><br></div><div>It was marked as a <a href="https://bugs.swift.org/browse/SR-128">bug</a> and then directed to <a href="https://github.com/ArtSabintsev/swift-evolution/blob/5ef676ec2616465c1cb854f82e3fd4e90b4b09c6/proposals/array-variadic-function.md">swift evolution</a>.</div><div><br></div><div>@jose, the prefix operator you mention looks good, but in the past discussions they wanted a postfix operator so that it would match the declaration.  I think I like the postfix operator.</div><div><br></div><div>func foo(_ a: String...) {}</div><div><br></div><div>foo([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]...) //&lt;- This looks clear.  It is turning the array into a variadic argument.</div><div><br></div><div>However, that thread was closed because it wasn&#39;t &quot;discussed&quot; enough prior making the pull request.</div><div><br></div><div>therefore, if people want it, they got to cast their vote in here by either supporting it or opposing it.</div><div><br></div><div>I like my original suggestion since it is more explicit.</div><div><br></div><div><div>foo([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] as String...) </div><div><br></div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Feb 26, 2017 at 7:59 PM Jose Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com">cheyo@masters3d.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Feb 26, 2017, at 8:26 AM, Derrick Ho via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-2241817684941310197Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg">In swift, a variadic argument can become an array without too much effort.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">func foo(_ va: String...) {</div><div class="gmail_msg">   let a: [String] = va</div><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">However, it seems odd to me that an array can not be converted into a variadic argument</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">foo([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]) // &lt;-error</div><div class="gmail_msg">foo(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) // no error<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><a href="http://stackoverflow.com/questions/24024376/passing-an-array-to-a-function-with-variable-number-of-args-in-swift" class="gmail_msg" target="_blank">Other people have wondered about this too.</a><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">According to <a href="https://devforums.apple.com/message/970958#970958" class="gmail_msg" target="_blank">this thread</a> Doug Gregor says it is due to some type ambiguity. with Generics.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">If type ambiguity is the issue, Do we have the option to cast it to the correct type?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">foo([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] as String...) // &lt;- error.  doesn&#39;t consider String... to be a type.<br class="gmail_msg"></div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I think this needs to be done with a spread operator in order to disambiguate. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">foo(...[&quot;a&quot;, &quot;b&quot;, &quot;c”] </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator" class="gmail_msg" target="_blank">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator</a></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I like the idea. Its syntactic sugar so I am not sure how open the core team would be to adding it. </div><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"></div></blockquote></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">What does the community think? Should we be granted some mechanism to turn an array into a variadic argument?</div></div></div></blockquote></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">
_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div></blockquote></div>