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 Basics Swift Types String Manipulation

Rex Stage
Rex Stage
97 Points


What am I doing wrong?

let name = "Rex" let greeting = "Hi There"

let interpolatedGreeting = "(greeting), (name)"

// Enter your code below

1 Answer

Andrew Boryk
Andrew Boryk
15,916 Points

First, I'd recommend separating your variables onto separate lines, it is easier to read considering that the variables are loosely related.

In addition, the format for string interpolation is: '\ (wordHere)' [Without the space between \ and (]. I suppose the markdown removed it in your question.

The question is also asking for two strings to be made, one named 'name' with the value of "Rex", and the other named 'greeting' with the value of "Hi there, (name)". I can understand the confusion after reading the question.

Here is a fixed answer:

let name = "Rex" 
let greeting = "Hi there, \(name)"

Hope this helps!

Rex Stage
Rex Stage
97 Points

Thank you. I understand what I was doing wrong.