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 Basics Swift Types Recap: Swift Types

could you please help me

i dont know what i have to do

types.swift
// Enter your code below

let firstValue: Int=3
let secondValue: Int=5

let product: Int = firstValue*secondValue
let 

4 Answers

Zachary Kaufman
Zachary Kaufman
1,463 Points

String interpolation is "like this but adding () within the string to input a value"

so...

// Enter your code below
let firstValue: Int = 1
let secondValue: Int = 2

let product: Int = firstValue * secondValue
let output: String = "The product of \(firstValue) times \(secondValue) is \(product)"

would return "The product of 1 times 2 is 2

i dint understand the last sentence could you explain it thank you

Zachary Kaufman
Zachary Kaufman
1,463 Points

Yes, so basically in Swift and most other languages, if you see "" it means that anything within the "" is a string. No matter what is in the "" it will be registered as a string according to the language. The exception is if you put () inside the "". So for example

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

What the program is ACTUALLY seeing is "The product of 1 times 2 is 2" because those are the values inside of (). DOes that make sense?

So what it would be the answer, I been trying but its not working the senteces and also I tried to make like this let output = (firstValue) * (secondValue) = (product)" but it didn't work as well.

Zachary Kaufman
Zachary Kaufman
1,463 Points

Can you send me all your code?

I actually did it, thank you sir