<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 7 févr. 2016 à 08:45, Jens Persson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="">let tenXs = String(count: 10, repeatedValue: Character("X"))</div><div class="">let tenYs = String(count: 10, repaetedValue: Character("Y"))</div><div class="">print(tenXs) // Prints XXXXXXXXXX</div><div class="">print(tenYs) // Prints (10, "Y")</div><div class=""><br class=""></div><div class="">So, why doesn't tenYs print the expected YYYYYYYYYY?</div><div class="">- Because of the slightly misspelled repeatedValues parameter label.</div><div class=""><br class=""></div><div class="">Then why no compile time error for the misspelled parameter label?</div><div class="">- Because of this String intializer: public init<T>(_ instance: T)</div></div><div class=""><br class=""></div><div class="">I guess there are other similar examples, but I happened to stumble upon this one just now.</div><div class=""><br class=""></div><div class="">Should they be considered a problem?</div><div class=""><br class=""></div><div class="">Is this an example of a problem that will be solved by removing tuple splat?</div>
</div></div></blockquote><br class=""></div><div>Looks like some kind implicit tuple "unsplating", the reverse of what is mentioned in SE-0029: Removing implicit tuple splat</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> sample</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">{</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span><T>(<span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> instance: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span>(instance)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> tenYs = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">sample</span>(count: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">10</span>, repaetedValue: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Character</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">"Y"</span>))</div><div class=""><br class=""></div><div class="">does display the same (10, "Y").</div><div class=""><br class=""></div><div class="">Dany</div></div><div><br class=""></div><br class=""></body></html>