Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift 2.0 Basics Swift Types Recap: Swift Types

Dawson Young
Dawson Young
512 Points

The string literal being assigned to output must be an interpolated string that evaluates firstValue, secondValue and pr

I am suppose to write interpolated string that says something but its not working UGH. My current code is: let firstValue = 4 let secondValue = 5 let product = firstValue * secondValue let output = "("The product of 4 times 5 is") (product)"

types.swift
// Enter your code below
let firstValue = 4
let secondValue = 5
let product = firstValue * secondValue
let output = "\("The product of 4 times 5 is") \(product)"

3 Answers

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey Dawson,

Phillip already gave you a hint. You can interpolate variables in a string by writing them inside of \(). You did that correctly with product, now you just have to do the same with firstValue and secondValue and not with the string around them.

Like this:

// Enter your code below
let firstValue = 4
let secondValue = 5

let product = firstValue * secondValue

let output = "The product of \(firstValue) times \(secondValue) is \(product)"
Phillip Paik
Phillip Paik
7,450 Points

The output should be: "The product of (firstValue) times (secondValue) is (product)"

( blah blah) Only variables and arrays and constants or math should go inside the "blah blah" For regular strings, you keep that outside of them.

Dawson Young
Dawson Young
512 Points

Thank you Phillip Paik and Tobias Helmrich! I understand now thanks to you two awesome dudes

Tobias Helmrich
Tobias Helmrich
31,603 Points

No problem! :) I'm glad you understand it now!