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