Question:

When this code is executed, what data type does convertedNumber have?

let possibleNumber = "1701"
let convertedNumber = Int(possibleNumber)

Correct answer: Int?.

Explanation: Creating an integer from a string will fail if the string does not contain a valid number. So, this constructor returns Int? to give you either a number (on success) or nil (on failure.)


Keywords:

© 2017 QuizBucket.org