Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between debugDescription and description methods of an array in swift?

Tags:

swift

Swift documentation says

debugDescription = A textual representation of self, suitable for debugging
description = A textual representation of self

in playground i get the output of both call as same

anArray.debugDescription // "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"
anArray.description // "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"

What is the actual difference between the two ?

like image 366
Aman Singh Avatar asked Jun 07 '15 03:06

Aman Singh


1 Answers

From Apple documentation:

an object's debug description is the same as its description. However, you can override debugDescription if you want to decouple these; many Cocoa objects do this.

So basically unless you add any extra functionality to your debugDescription it will be the same as description.

like image 140
Icaro Avatar answered Nov 09 '22 23:11

Icaro