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

types.swift

This looks right, but it's telling me that I'm wrong, even though the preview tells me there is nothing wrong with it. Help please?

types.swift
// Enter your code below

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

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

4 Answers

Tobias Helmrich
Tobias Helmrich
31,601 Points

Hey there,

good job, you almost got it right! The problem is that you're setting the product constant to the String "firstValue * secondValue". To multiply the values you have to remove the quotes around the calculation like so:

// Enter your code below

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

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

I hope that helps! :)

Ahmet GULER
Ahmet GULER
7,181 Points

you are putting let product constant value inside quotes " ". so product constant is becoming a String.

Ahmet GULER
Ahmet GULER
7,181 Points

let product = firstValue * secondValue

this way it will stay as an Integer

Thanks both so much :) Really new to Swift so feel kinda stupid that I made such a simple mistake. Thanks for your quick and helpful replies though :)

Tobias Helmrich
Tobias Helmrich
31,601 Points

I'm glad I could help! But you shouldn't feel stupid now, simple mistakes happen to all of us. Keep up the good work! :)

Thanks very much :D