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 trialBob Clanfield
2,372 PointsIOS Swift String interpolation. Are all these wrong? None seem to work.
let name = "Bob" let greeting = "Hi there, (name) " let finalGreeting = greeting
let name = "Bob" let finalGreeting = "Hi there, (name) "
let name = "Bob" let greeting = "Hi there," + name
// Enter your code below
//let name = "Bob"
//let greeting = "Hi there, \(name) "
//let finalGreeting = greeting
//let name = "Bob"
//let finalGreeting = "Hi there, \(name) "
let name = "Bob"
let greeting = "Hi there," + name
2 Answers
Todd Anderson
4,260 PointsThe code you have commented out is correct, but might not be formatted exactly how they wanted.
greeting = "Hi there, \(name)"
Here greeting is interpolated (without space after name).
Also, finalGreeting should be a concatenation using greeting
finalGreeting = greeting + " How are you?"
notice the space before How so that it matches when the strings are added together.
Complete answer:
let name = "Todd"
let greeting = "Hi there, \(name)"
let finalGreeting = greeting + " How are you?"
Bob Clanfield
2,372 PointsHi Todd, I finally figured it out. Part of the issue was that I didn't understand that it was not a second task , rather a continuation of the first. Many Thanks for your reply! ĀÆ_(ć)_/ĀÆ ą„