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

San Francisco
San Francisco
28,373 Points

Challenge 2 of 2 https://teamtreehouse.com/library/swift-20-basics/swift-types/recap-swift-types

What is the proper format for this to work?

Thanks

types.swift
// Enter your code below
let firstValue = 69
let secondValue=70
let product = firstValue * secondValue 
let output = "The product of (\firstValue) + 'times' + (\secondValue) 'is' + (\product)"


 ______ 
| derp |
 ------ 
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

1 Answer

I think the backslash comes before the bracket - \(varName). Also, you don't need the + signs as you are not concatenating the strings - everything is enclosed within the inverted commas, so the whole thing is a string, just with the variable values interpolated in there. Example below.

I hope that helps.

Steve.

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