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 trialAnna Benson
2,728 PointsAm I incorrectly creating interpolated strings?
I thought I was correctly following the syntax for interpolated strings shown in the examples in the video, but I keep getting an error message pop up for this code challenge saying "Make sure the value for greeting is an interpolated string."
What is wrong with my code for the constant greeting?
// Enter your code below
let name = "Anna"
let greeting = "\("Hi there,") \(name)\(".")"
2 Answers
Nathan Tallack
22,160 PointsLike this.
let greeting = "Hi there, \(name)."
You write your string literally normally. That's the stuff between the "" quotes. Anytime you want to insert a value in there, like we did with the constant "name" above you pop the value inside of the () brackets. Because we want it to understand the bracket we escape the opening bracket with the \, otherwise it will think you just want to include the brackets in your string literal.
Hope this helps. :)
Ashleigh Nombre
2,308 PointsIf you have any trouble with other problems my skype is open for questions on these modules. Skype: ashleigh.nombre
Anna Benson
2,728 PointsThank you! I may take you up on that sometime!
Anna Benson
2,728 PointsAnna Benson
2,728 PointsThank you so much! That was way simpler than I thought.