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 String Manipulation

Dave Hanna
PLUS
Dave Hanna
Courses Plus Student 2,969 Points

Swift 2.0 Basics: Getting an error for Challenge Task 1 of 2

let name = "Dave." let greeting = "Hi there, "

let InterpolatedGreeting = "(name) (greeting)"

What am I doing wrong?

4 Answers

Dave Hanna
PLUS
Dave Hanna
Courses Plus Student 2,969 Points

// Enter your code below let name = "Dave." let greeting = "Hi there, (name)"

let InterpolatedGreeting = "(greeting)"

This way worked best

I think you are missing the backslash \ in front of the interpolated string (someVariable). For example, the format of an interpolated string with two variables should look like this...

let someString = "\(someVariable) with some \(otherVariable)"

Hope this helps.

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,736 Points

You need the backslash before the parentheses for string interpolation. Also the order that you're putting these variables in is going to print out "Dave. Hi there,"

Christin Lepson
Christin Lepson
24,269 Points

First off, make sure your code statements are on separate lines. Also, your variable 'InterpolatedGreeting' should start with a lowercase 'i'. You need forward slashes before your interpolated strings, like this:

let name = "Dave."
let greeting = "Hi there, "
let interpolatedGreeting = "\(greeting) \(name)"