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 trialRyan Maneo
4,342 PointsSwift Test Issue
Hello, I am taking Swift 2.0 Basics. I am on String Interpolation. It gave me instructions to create a constant named "name" and assign it to a string containing my name, which I did as you can see below. It then told me to create a constant named "greeting" and assign it to "Hi there," and an interpolated string in the form of "(name)."
I have tried SEVERAL combinations, and none seem correct. They said the final message should read: "Hi there, Ryan." Which it does in my playground, but it says I am getting it wrong here... what should I do?
let name = "Ryan" let greeting = "Hi there," + "(name)."
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsIf you're using string interpolation, you need to put the backslash before the parentheses. String concatenation is cool too, which is when you add strings together using the plus sign - but this isn't what they're asking for yet. What you did is sort of both string concatenation and string interpolation, but without the backslash. Let's just do string interpolation for now. I think you use string concatenation in the next exercise.
let name = "Ryan"
let greeting = "Hi there,\(name)"
Ryan Maneo
4,342 PointsRyan Maneo
4,342 PointsIt told me to add a period after the (name)... so I did... I also did use a backlash It just didnt show in my copy/paste for some reason... thanks though. Moving on! :)