What output will be produced by the code below?

let string: String = String(describing: String.self)

Correct answer: "String".

Explanation: Among the many constructors for strings is one that lets you pass in a class to have the string set to the name of that class. That is, String(describing: String.self) means "create a string out of the name of the String class." This is equivalent to the NSStringFromClass() function that Objective-C developers often use.



© 2017