Complete the code to convert an Int to a String explicitly.
let number = 42 let text = String([1])
In Swift, to convert an Int to a String, you use String(number). This is an explicit conversion.
Complete the code to convert a String to an Int explicitly.
let text = "123" let number = Int([1])
To convert a String to an Int in Swift, use Int(text). This returns an optional Int.
Fix the error in the code by completing the explicit conversion.
let pi = 3.14 let integerPi = [1](pi)
To convert a Double to an Int explicitly, use Int(pi). This truncates the decimal part.
Fill both blanks to convert a String to a Double explicitly and then to an Int.
let text = "56.78" if let doubleValue = [1](text) { let intValue = [2](doubleValue) }
First convert the String to a Double using Double(text). Then convert the Double to an Int using Int(doubleValue).
Fill all three blanks to convert an Int to String, then to Double, and finally to Int again.
let number = 100 let text = [1](number) if let doubleValue = [2](text) { let finalInt = [3](doubleValue) }
Convert Int to String with String(number), then String to Double with Double(text), and finally Double to Int with Int(doubleValue).