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 trialAngel Caro
11,831 PointsSwift basics 2.0 string interpolation.
After watching the videos i thought i had a pretty good grasp on this, and when i took the code challenge it said it was wrong but it works in Xcode. This is the code i used in Xcode: let interpolatedGreeting = "(greeting), (name)." which is what was taught on the lesson but the answer required this: let greeting = "Hi there, (name)" and that would work on the challenge but not Xcode, Please advise.
5 Answers
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsIt looks like you're missing the backslash:
let greeting = "Hi there, \(name)"
Angel Caro
11,831 PointsThe second answer i posted was the answer someone posted on the forum which works on the challenge. The first line of code in my question works on Xcode but it won't pass the challenge.
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsBoth are missing the backslash necessary for string interpolation. If it passed the challenge, it shouldn't have.
Angel Caro
11,831 PointsIt passed without the backslash, it would not pass with it. Thats why i'm confused, thanks for your answer.
Dustin Honeck
12,504 PointsYou may have used a forward slash by accident.
Dustin Honeck
12,504 PointsYou may have used a forward slash by accident.