<div dir="ltr"><div>Clear.<br></div>For my needs, this chunk of code at the beginning of my file is sufficient:<br><br><div style="margin-left:40px">#if !_runtime(_ObjC)<br>extension String {<br>    public func hasPrefix(prefix: String) -&gt; Bool {<br>        return prefix == String(self.characters.prefix(prefix.characters.count))<br>    }<br>    public func hasSuffix(suffix: String) -&gt; Bool {<br>        return suffix == String(self.characters.suffix(suffix.characters.count))<br>    }<br>}<br>#endif<br></div><br><div>Thank you guys!<br></div><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 11, 2015 at 12:51 PM, Alex Blewitt <span dir="ltr">&lt;<a href="mailto:alex.blewitt@gmail.com" target="_blank">alex.blewitt@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">FYI:<div><br></div><div><a href="https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L73" target="_blank">https://github.com/apple/swift/blob/master/stdlib/public/core/StringLegacy.swift#L73</a></div><div><br></div><div>These two functions are (currently) only available with the Objective-C bridge, which the Linux port doesn’t have.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Alex</div></font></span><div><div class="h5"><div><br><div><blockquote type="cite"><div>On 11 Dec 2015, at 11:48, Alex Blewitt &lt;<a href="mailto:alex.blewitt@gmail.com" target="_blank">alex.blewitt@gmail.com</a>&gt; wrote:</div><br><div><div style="word-wrap:break-word">They may come as extensions from NSString, which Swift doesn’t have fully implemented on Linux yet.<div><br></div><div>Alex</div><div><br><div><blockquote type="cite"><div>On 11 Dec 2015, at 11:18, Alessandro Morgantini via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br><div><div dir="ltr"><div><div><div><div><div>Hello to everyone!<br></div>I&#39;m a very newbie to Swift, I&#39;m doing first experiments on Linux &amp; Mac and I have the following issue: if I call the hasSuffix(_:) or the hasPrefix(_:) methods on a String instance, I obtain the following error:<br><br><div style="margin-left:40px">$ swiftc prova.swift<br>prova.swift:110:4: error: value of type &#39;String&#39; has no member &#39;hasSuffix&#39;<br>if pippo.hasSuffix(&quot;ao&quot;) {<br>   ^~~~~ ~~~~~~~~~<br></div><br></div>Same code works well on OS X.<br></div>I&#39;m using Ubuntu 14.04 with required dependencies (clang and libicu-dev) installed.<br></div>Any idea?<br><br></div>Cheers, Alessandro<br clear="all"><div><div><div><div><div><div><br>-- <br><div>Ing. Alessandro Morgantini - <a href="http://www.morgantini.org/" target="_blank">http://www.morgantini.org/</a><br>Email: <a href="mailto:gpz500@technologist.com" target="_blank">gpz500@technologist.com</a><br>Cell.: <a href="tel:%2B39-347%20761%201221" value="+393477611221" target="_blank">+39-347 761 1221</a> - Fax: +39-390 347 761 1221</div>
</div></div></div></div></div></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=4UsVFgIJDmjEl1-2Bp4dkDdfPyHFijFe3gbZsM1qGcraVVqTtvGFDuzZdI74U2KtedTG81HrpqxUOZZlD6f7Xs3DTxUtOKkwoJxGudabJubIMOGkmj3R-2FcyR1ozB0pKqAi43a4KC2Sx0eXISjkxDcxcG6hAfETVL6RIFqubhgHQtmJXMmgl1XAwyg2ZdMuEwZGIqJTzKJE8jP2absyTIOVfoLGbI2IzcYza1T-2F7fIS-2Fcw-3D" alt="" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" border="0" height="1" width="1">
_______________________________________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Ing. Alessandro Morgantini - <a href="http://www.morgantini.org/" target="_blank">http://www.morgantini.org/</a><br>Email: <a href="mailto:gpz500@technologist.com" target="_blank">gpz500@technologist.com</a><br>Cell.: +39-347 761 1221 - Fax: +39-390 347 761 1221</div>
</div>