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 trialChad Crabb
1,142 PointsI think my code should work. Why is it not?
let firstValue: Int = 5
let secondValue: Int = 7
let product: Int = firstValue * secondValue
let output: String = "The product of (firstValue) times (secondValue) is (product)"
// Enter your code below
let firstValue: Int = 5
let secondValue: Int = 7
let product: Int = firstValue * secondValue
let output: String = "The product of \(firstValue) times \(secondValue) is \(product)"
1 Answer
Richard Lu
20,185 PointsHi Chad,
The code you have is definitely correct, but I think what the instructor wants to emphasize is type inferencing (allowing the compiler to figure out the types). Here's what he wants:
// Enter your code below
let firstValue = 5
let secondValue = 7
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
EDIT: 10.26.15
The challenge has been fixed, and you can now have your solution look like this with the types:
// Enter your code below
let firstValue: Int = 10
let secondValue: Int = 5
let product: Int = firstValue * secondValue
let output: String = "The product of \(firstValue) times \(secondValue) is \(product)"