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

Abdullah Tharwat
PLUS
Abdullah Tharwat
Courses Plus Student 192 Points

I'm stuck here

I can't declare an interpolated string to be at the end " the product of 2 times 4 is 8 " firstValue = 2 secondValue = 4 product = 8

types.swift
// Enter your code below

let firstValue : Int = 2
let secondValue : Int = 4

let product : firstValue * secondValue = 8
let firstly = "the product of"
let output = "\(firstly), \(firstValue) * (secondValue) \(product)"

1 Answer

Hello Abdullah,

There are a few small mistakes in your code.. let's fix them.

On the "product" constant, you are not declaring anything there. The syntax is incorrect.

/// Lets do something like this

let product: Int = firstValue * secondValue

Remember, that when you do a declaration, you do not need to explicitly show the type you are declaring, the system will infer it for you, unless its ambiguous and it must be declared.

/// Instead you can do something like this

let product = firstValue * secondValue

Now, your output should look exactly as the requirement asks you.. including spelling, otherwise the system will not accept the answer.

/// Output with string interpolation 
let output = "The product of \(firstValue) times \(secondValue) is \(product)"

I hope this helps you solve your problem.

Good luck

Abdullah Tharwat
Abdullah Tharwat
Courses Plus Student 192 Points

You’re great , I see where my mistake was , thank you for helping :)

For the challenge to pass the value of output should be

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

times not time