iOS Swift Basics Swift Types Recap: Swift Types

Interpolating string literals

Having a little bit of trouble with string interpolation and how that will work with broken up string literals. I'm not sure that I've seen string interpolation before, honestly.

let firstValue = 3
let secondValue = 5
let product = firstValue * secondValue
let output = "\(The product of), \(firstValue), \(times), \(secondValue), \(is), \(product)"

1 Answer

Daniel Turato
.a{fill-rule:evenodd;}techdegree seal-36
Daniel Turato
Java Web Development Techdegree Graduate 30,121 Points

With String interpolation , you only surround the embedded data with \ () and not the actual normal string writing. So, your output constant should look like this:

let output = "The product of \(firstValue) times \(secondValue) is \(product)"