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 trialJorge Castillo
820 Pointswhy this code is working on my Xcode and not in the test area
let name = "Jorge."
let greeting = " ("Hi there,") (name)"
// Enter your code below
let name = "Jorge."
let greeting = " \("Hi there,") \(name)"
6 Answers
Pavel Fomchenkov
20,897 PointsOk, I got it. It could be a test area trouble. You can actually write it like
let greeting = "\("Hi there"), \(name)"
That is right. But it is unnecessary to interpolate [use the \()
construct in] an actual string inside a string. Just write it "as is" like that:
let greeting = "Hi there, \(name)"
Jorge Castillo
820 PointsThanks, Pavel. You clarified properly the concept I got it I do not the () for the first string.
Thanks so much again. Have a good night
Jorge
Pavel Fomchenkov
20,897 PointsYou do not need to write "\("strings inside the parentheses")" to output regular text, just "write the text and \(non_string_vars) inside the parentheses". Also there is just an extra space before the first quote-slash.
Jorge Castillo
820 PointsThanks, not working in that way
Pavel Fomchenkov
20,897 PointsWhat code do you use now? I don't want to give you the answer but some hints.
Jorge Castillo
820 PointsI typed this on Xcode and not error as test area. let name = "Jorge."
let greeting = "("Hi there,") (name)"
let finalGreeting = "(greeting) ("How are you?.")"
Thanks, Pavel