<div dir="ltr"><p>Wait, it looks like <code>String(byRepeatingString: aString, count: 3)</code> only works on characters and was removed, replace it with <code>aString + aString + aString</code>.</p>
<br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 10, 2016 at 7:38 PM Saagar Jha &lt;<a href="mailto:saagarjha28@gmail.com">saagarjha28@gmail.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 dir="ltr"><p>Yes, that’s what I meant. Basically, I see stuff like this:</p>
<pre><code>func tripleForceUnwrapping(aString: String!) -&gt; String {
    return String(byRepeatingString: aString, count: 3)
}
</code></pre><p>and later users get a crash with this:</p>
<pre><code>let possiblyNilString = someFunctionThatRetunsAnOptional()
tripleForceUnwrapping(possiblyNilString)
</code></pre><p>even though it compiles fine.</p>
<pre><code>func tripleWithoutUnwrapping(aString: String?) -&gt; String {
    return String(byRepeatingString: aString, count: 3)
}

let possiblyNilString = someFunctionThatRetunsAnOptional()
tripleWithoutUnwrapping(possiblyNilString)
</code></pre><p>meanwhile, doesn’t compile and forces the user to think “huh, it’s not compiling because there’s an Optional” and hopefully add a check</p></div><div dir="ltr">
<br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 10, 2016 at 7:18 PM Paul Cantrell via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
&gt; On Jun 10, 2016, at 7:43 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; on Thu Jun 09 2016, Saagar Jha &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Yes, that’s exactly my point. Force unwrapping optionals adds<br>
&gt;&gt; confusion for new users; all too often I see newcomers ending up with<br>
&gt;&gt; the assumption that the force unwrapping takes care of the check for<br>
&gt;&gt; them.<br>
&gt;<br>
&gt; ...but, it *does*.<br>
<br>
I took Saagar to mean “the assumption that force unwrapping takes care of doing the right thing for them so they don’t ever have to think about nil at all.” Which is indeed quite common in beginner Swift code.<br>
<br>
Sadly, there is no compile-time check for mindfulness.<br>
<br>
Cheers, P<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">-Saagar Jha</div></div></blockquote></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">-Saagar Jha</div></div>