We can use the debugDescription
property on a string instance to return the representation of the string suitable for debugging.
string.debugDescription
This property returns the representation of the string suitable for debugging.
Let’s look at the code below:
// create some stringslet name = "Theodore"let language = "Swift"let emptyString = ""// get debugDescription propertylet debugDesc1 = name.debugDescriptionlet debugDesc2 = language.debugDescriptionlet debugDesc3 = emptyString.debugDescription// print resultsprint(debugDesc1) // "Theodore"print(debugDesc2) // "Swift"print(debugDesc3) // ""
debugDescription
properties of the strings we created.