I wonder why the description method of collections use the debugDescription 
method to print their elements, and not the description method.

Dmitri Gribenko gave this reason in December 2015 [1]:

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:

var myArray = [ "", "", "" ]

If we used the regular description, then String(myArray) would be
"[  , , ]", which looks like a library bug.

[1]: https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000272.html

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to