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 trialWilliam Nguyen
2,998 PointsI think something wrong. I think it is always right
Why is it error ? please explain for me. Thanks
// Enter your code below
let name = "Linda"
let greeting = "Hi there," + "\(name)" + "."
3 Answers
Jennifer Nordell
Treehouse TeacherI'm guessing you've done programming in other languages that uses the + symbol to concatenate strings together. This is not how it works in Swift. Try this code for the greeting constant instead:
let name = "Linda"
let greeting = "Hi there, \(name)."
Jason Anders
Treehouse Moderator 145,860 PointsHey William,
Jennifer is correct for this challenge. But this challenge is not about concatenation. It is about using `String Interpolation". You have a little of both in you answer.
This string would be close to what you have, if the challenge was asking for concatenation.
let greeting = "Hi there, " + name + "." //Concatenated String in Swift
Please refer to Jennifer's response for the correct interpolated string.
Hope this helps. Keep Coding!
William Nguyen
2,998 PointsThanks all !!
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsHey Jennifer Nordell
Swift does actually use the + symbol for concatenation, like most other languages. What you are doing here is "String Interpolation", which is another way to join up strings in Swift. Both have pros and cons depending on what you are trying to accomplish, but both are valid ways in Swift.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherAs Jason has pointed out, and I was unclear about Swift does also use concatenation. But they specifically asked for interpolation which is different. Sorry to muddy the waters here :)
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsAll good Jennifer.
There are times I muddle up the syntax of different languages. :)
Thank you for your participation in the Community Forums.