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

John Henry Dale
John Henry Dale
360 Points

I'm having trouble with the swift types quiz, can someone please chime in ?

I've tried to do what the instructions ask and can't seem to get a proper result. Specifically I'm not sure where / how the string assigned to output "The product of 2 times 4 is 8" is supposed to be declared

types.swift
// Enter your code below
let firstValue = 2
let secondValue = 4
let product = "\(firstValue) * \(secondValue)"
let output: String = "The product of 2 times 4 is 8"

//have to do it like this

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

1 Answer

Tobias Helmrich
Tobias Helmrich
31,601 Points

Hey there,

firstly you don't have to use interpolation when calculating the product, just multiply the two values. The problem with your output constant is that you're just writing the numbers inside of the String manually but you have to use String interpolation, like you did in the product constant, so that the output changes depending on the values.

This is a working example:

// Enter your code below
let firstValue = 2
let secondValue = 4
let product = firstValue * secondValue
let output: String = "The product of \(firstValue) times \(secondValue) is \(product)"

If you have further questions feel free to ask, good luck! :)