iOS Swift Basics Swift Types Recap: Swift Types

Abdullah Tharwat
PRO
Abdullah Tharwat
Pro 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

Jhoan Arango
MOD
Jhoan Arango
Treehouse Moderator 12,799 Points

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
Pro Student 192 Points

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

Kyle Vandeven
Kyle Vandeven
13,382 Points

For the challenge to pass the value of output should be

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

times not time