<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 11, 2015 at 1:38 PM, Wojciech Czekalski via swift-dev <span dir="ltr"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></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">Hi,<div><br></div><div>while I was working on <a href="https://github.com/apple/swift/pull/348" target="_blank">this</a> PR I encountered unexpected behavior from <font face="Menlo">Array.description</font>. It iterates over its items and calls <font face="Menlo">debugDescription </font>on them. I found it a bit unexpected thus my question here. Is it desired behavior? I would expect <font face="Menlo">description</font> and <font face="Menlo">debugDescription</font> call respective methods on the contents.</div></div></blockquote><div><br></div><div>Array's description shouldn't be presented to the user in raw form, ever, so the use case here is debugging. Thus, it makes sense to present the debug representation of the elements in both cases. Consider an array of strings:</div><div><br></div><div>var myArray = [ "", "", "" ]</div><div><br></div><div>If we used the regular description, then String(myArray) would be "[ , , ]", which looks like a library bug.</div><div><br></div><div>Dmitri</div></div><div><br></div>-- <br><div class="gmail_signature">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>>*/</div>
</div></div>