We use the description
property of a Dictionary
instance to get the string representation of the contents of that Dictionary instance.
dictionary.description
The value returned is a string. This string represents the contents of the Dictionary instance, dictionary
's, entries.
// create a dictionayvar techGiants = ["G" : "Google","N" : "Netflix","Ap" : "Apple","Am" : "Amazon","M" : "Meta"]// get the string representationslet stringified = techGiants.description// print string contentsprint(stringified)// check typeprint(type(of: stringified)) // String
techGiants
. We then populated it with some entry values.string
. Then, we store the result in a variable called stringified
.type(of:)
method. We then print the value to the console.