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 trialAndrea Gorodezky
1,255 PointsPLEASE HELP ME WITH STRING INTERPOLATION!!! Why is this wrong?
please
// Enter your code below
let name = "Andrea"
let greeting = "Hi there, \(name) \."
1 Answer
ianhan3
4,263 PointsYou added an extra \ to your string. Think of String Interpolation as a placeholder for your parameter, variable, constant, etc.
So for you:
let name = "Andrea"
let greeting = "Hi there, \(name)."
or another example:
var petThatILove = "cats"
let sentenceIUseOftenOnTheInternet = "I love \(petThatILove)."
which if printed (print()) would say "I love cats."
Ghaith Ali
3,134 PointsGhaith Ali
3,134 Pointsi think you have a problem with the syntax of String interpolation, this is how i would do it:
I think your problem is that you are adding the extra back slash at the end, that causes the compiler to expect a function. hope my answered helps