<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div>On Jul 23, 2017, at 09:15, Matheus Martins via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div>I came across what i think is an inconsistency in the standard library.</div><div><br></div><div>Why are some numeric types like Int not conforming to LosslessStringConvertible by default while Float and Double do conform to it in the standard library?</div><div><br></div><div>I came across this while trying to write some generic code:</div><div><br></div><div><div>func array&lt;T: LosslessStringConvertible&gt;(_ text: String) -&gt; [T?] {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>return text.components(separatedBy: " ").map { T($0) }</div><div>}</div></div><div><br></div><div>It seems rather inconsistent to me that that allows me to do:</div><div><br></div><div>let floats: [Float] = array("1.0 2.2 3")</div><div><br></div><div>but i can't do:</div><div><br></div><div>let ints: [Int] = array("1 2 3 4 5 6")</div><div>"<span style="color:rgb(255,255,255);font-family:Inconsolata,Monaco,Menlo,'Ubuntu Mono',Consolas,source-code-pro,monospace;font-size:13px;background-color:rgb(38,74,96)">type 'Int' does not conform to protocol 'LosslessStringConvertible'</span>"</div><div><br></div><div>To further my point, Int is used as the sole example in the LosslessStringConvertible docs: <a href="http://swiftdoc.org/v3.0/protocol/LosslessStringConvertible/">http://swiftdoc.org/v3.0/protocol/LosslessStringConvertible/</a></div><div>Yet it does not actually conform to it.</div><div><br></div><div>This seems way too basic for me to feel comfortable pitching it here, but i searched and couldn't find any discussion on this on any mailing list or website.</div></div></div></blockquote><br><div>Sounds like it's a bug to me, either in the docs or stdlib, depending on the intended behavior. Although I doubt they would've used Int in the docs if they weren't intending Int to conform to it.</div><div><br></div><div>- Dave Sweeris</div></body></html>