Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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)."