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 Basics Swift Types String Manipulation

Cruiz Thomason
Cruiz Thomason
1,085 Points

Having a hard time trying to figure out that last part of this question? I don't know how else to write it...

let interpolatedGreeting = "(greeting), (name)" this isn't right but I thought that would be and don't know how else it wants me to write it out.

strings.swift
// Enter your code below
let name = "Cruiz"
let greeting = "Hi there"

11 Answers

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

You can use string interpolation to write out the greeting. Looks like you are missing the \ which is found on the keyboard above the return key. Try:

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

Cruiz Thomason
Cruiz Thomason
1,085 Points

I have tried this but still seems to pop up as wrong and not sure why.

Make sure that each statement is on a separate line. Also make sure you are using \ instead of /

if that isn't working make sure to reread the question and that you are following the instructions exactly. Often times you can be missing simple details

Cruiz Thomason
Cruiz Thomason
1,085 Points

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

This is exactly how I have it written out

Cruiz Thomason
Cruiz Thomason
1,085 Points

This is the question that goes along with my answer:

In this task we're going to declare two strings. First, declare a constant named name and assign to it a String containing your name.

Second, declare a constant named greeting. Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant.

As an example, the final value of greeting could be "Hi there, Linda".

Based on the question you need to:

let name = "Cruiz"

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

Looks like you made an extra variable. What you did technically works but isn't answering the question how it is assigned. They ask you to interpolate the value for greeting.

Cruiz Thomason
Cruiz Thomason
1,085 Points

let name = "Cruiz"

let greeting = "Hi there (name)."

this is still showing as wrong.

Cruiz Thomason
Cruiz Thomason
1,085 Points

and I don't know why when I post this it's taking out the forward slash .

try adding a comma. I noticed that too. I've been using two forward slashes and it seems to appear as one

Cruiz Thomason
Cruiz Thomason
1,085 Points

haha. That finally worked. Thanks for your help!

Cruiz Thomason
Cruiz Thomason
1,085 Points

// Enter your code below let name = "Cruiz"

let greeting = "Hi there, (name)"

let finalGreeting = "How are you?"

I'm suppose to concatenate the final line. How else do I do that?

"Hi there, \(name) \(finalGreeting)" - If there is a comma after the name make sure to add it "Hi there, \(name), \(finalGreeting)"