Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics Swift Types String Manipulation

aren polat
aren polat
883 Points

i am stuck in this question

I think i understood the question wrong but im stuck

strings.swift
// Enter your code below
let name = "aren"
let greeting = "\(hiThere,), \(name)"

6 Answers

Patrik Horváth
Patrik Horváth
11,097 Points
// Enter your code below
let name  = "name"
let greeting = "Hi there, \(name)"

I can see that there is abit of confusion in the answering of your question so i'd like to offer my help. I have written out the correct code below and will give it a bit of explanation now.

You have done the code 95% correct but its just the greeting constant that has the error. Only the name should be in brackets. As the greeting constant is a string, you simply write it like a normal string e.g. "Hi There". Then to pull the name constant into the string, you add (name) before you close the string... this would then read as "Hi there, (name)".

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

Second statement should be like this, let greeting = " hi There, (name)"

Yes

Patrik Horváth
Patrik Horváth
11,097 Points

why you post "Yes" as answere ?

I mean put (name)

When I try to print backward slash it don't show in my answer. My answer is backward slash and (name) in string.

Patrik Horváth
Patrik Horváth
11,097 Points

use forum CODES its little bit up when you POSTING comment =)