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

Question is saying that my string literal being assigned to output but be an interpolated string.

let firstValue = 2 let secondValue = 4

let product = firstValue * secondValue

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

types.swift
// Enter your code below
let firstValue = 2
let secondValue = 4

let product = firstValue * secondValue 


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

6 Answers

Jose Patarroyo
Jose Patarroyo
2,953 Points

Hello,

To give a String value to the output constant, you should use the syntax:

"The product of x times y is z". Since you want to call the data stored on first and second value, the way to do it is like this:

"The product of (firstValue) times (secondValue) is (product)"

As you can see, the special character () call the data stored in the constants rather than writing the names of the constants (firsValue or secondValue)

Jose Patarroyo
Jose Patarroyo
2,953 Points

Jus want to add, that for some reason the back slash was removed from my previous post. The syntax for the constants within the " " should be:

backSlash()

Hope you can understand what I mean

Jose it is still giving me an error message.

Jose Patarroyo
Jose Patarroyo
2,953 Points

can you show me your code?

Jose Patarroyo
Jose Patarroyo
2,953 Points

I found a way to write code within the post, let's see if it works. The correct syntax should be:

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

Notice I only used the back slash followed by parentheses only when I want to view the data stored in the constants

thank you jose, I was just missing the string interpolation bout your code was right.

"The product of (firstValue) times (secondValue) is(product)."