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

Noquisi Burgess
Noquisi Burgess
238 Points

frustrated and depressed wanting to progress....

This is the best that Ive came up with. I really dont get this...I watched the video like 3 times on string interpolation. Are my back slashes and parentheses correct, added that after watching the video again thinking it would work but still no luck....

types.swift
// Enter your code below

let firstValue = 2

let secondValue = 4

let product = "firstValue * secondValue"

let output = "The /(product) of /(firstValue) * /(secondValue) is 8"

1 Answer

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey Noquisi,

don't give up! :) There are a few mistakes in your code but you were close to get it right!

  • You have to do assign the result of the calculation to product but you're writing the multiplication inside of quotes which means that the String "firstValue * secondValue" is saved but not the resulting number. To get it right you have to remove the quotes around it
  • In the output constant you first have to write "The product..." and not the value of product which means that you don't have to interpolate in the beginning but just write "product" as a String
  • To interpolate you have to write the constant/variable inside of \() . You almost got it right but make sure it's a backslash instead of a forward slash
  • Make sure to write the exact same String the challenge wants you to write. So instead of "*" you have to write "times"
  • Also in the output constant make sure to not "hardcode" the result in the end but interpolate the product constant

If you fix those issues it should look like this and work:

// Enter your code below

let firstValue = 2

let secondValue = 4

let product = firstValue * secondValue

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

I hope that helps, don't get frustrated or depressed and keep up the good work! :)