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 trialXO Error
877 Pointslet name = "Sheldon" let greeting = "\("Hi there, ") \(name)\(".")" works fine in xcode but not here. Refuses to pass.
let name = "Sheldon" let greeting = "("Hi there, ") (name)(".")" Passes in xcode fine without error, but will not work here.
// Enter your code below
let name = "Sheldon"
let greeting = "\("Hi there,") \(name)\(".")"
3 Answers
Carl Smith
8,185 PointsSo the second string you put together should look like this.
let greeting = ("Hi there, \(name).")
whenever you put () around something, that's calling the stored information you assigned to that variable to be used. you created a variable called "name" so you only need that around "name" to call that variable to be interpolated into your string. Interpolated is a big and confusing word so I like to think of it as adding something to the string without using a plus sign like you would in concatenation.
Hope this helps!!!
XO Error
877 PointsThank you for the response it was helpful! Would there be a closed double quote at the very end?
XO Error
877 Pointslet greeting "Hi there, (name)." ended up working. Thanks!
Carl Smith
8,185 PointsCarl Smith
8,185 PointsYes there would, it cut that part out for some reason. Glad I was able to help!