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 trial

iOS Swift 2.0 Basics Swift Types String Manipulation

why this code is working on my Xcode and not in the test area

let name = "Jorge."

let greeting = " ("Hi there,") (name)"

strings.swift
// Enter your code below
let name = "Jorge."

let greeting = " \("Hi there,") \(name)"

6 Answers

Pavel Fomchenkov
Pavel Fomchenkov
20,897 Points

Ok, 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)"

Thanks, 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
Pavel Fomchenkov
20,897 Points

You 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.

Thanks, not working in that way

Pavel Fomchenkov
Pavel Fomchenkov
20,897 Points

What code do you use now? I don't want to give you the answer but some hints.

I 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