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

Nate Drexler
Nate Drexler
1,883 Points

I'm stuck on this code challenge. See code below:

I thought I formatted the interpolation correctly

// Enter your code below
let name = "Nate Drexler" 

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

2 Answers

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hey Nate,

There are a couple issues going on here.

  • You can not interpolate a string. Only variables / constants can be interpolated, so "Hi There," should not be enclosed in parenthesis.

  • The period needed cannot be added inside of a interpolated variable. You can add this two ways: After the closing parenthesis for the name variable but before the closing quote. Or just add in to the end of the value assigned to the name variable (I chose the latter).

Other than that... looks good. Below is the corrected code for you to reference. I hope it makes sense.

let name = "Nate Drexler." 

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


Nate Drexler
Nate Drexler
1,883 Points

Thank you much, Jason. Makes perfect sense.

Cindy Lea
Cindy Lea
Courses Plus Student 6,497 Points

let name = "Linda" let hello = "Hi there" let greeting = "(hello), (name)."