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 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