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 Strings

i seem to have a problem with the interpolation question on swift , i dont know where im getting it wrong

i have tried

let name ="Brian"

let greeting = "Hi there, \(name)

its not working please help

[MOD: edited code block - srh]

Raphael Reiter
Raphael Reiter
6,820 Points

Hello, you are missing a " after (name) ;-) =

let greeting= "Hi there, (name)"

To avoid this problem in the future, I have a little trick, i always put the 2 "" and then write in the middle. same for () and {} and []

4 Answers

Hi!

You need to close the string with another " mark at the end:

let greeting = "Hi there, \(name)" // <- that's missing! 

Steve.

joe Bell Fenner
joe Bell Fenner
Courses Plus Student 2,646 Points

this aint working for either I'm still getting " Bummer! Make sure the value you are assigning to greeting is an interpolated string"

Show me your code, Joe! :smile:

joe Bell Fenner
PLUS
joe Bell Fenner
Courses Plus Student 2,646 Points

sorry I dont know how to include the screen shot. but anyway I typed the following..

let name = "Joe"

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

also tried..

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

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

all sorts of variants.

Hi Joe,

I think you start with creating a name constant:

let name = "Joe"

Then you want to interpolate name into a greeting constant (just like you've done in your first lines?!):

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

However, I've just tried this and it isn't working - this is the third Swift issue I've come across tonight - I think there may be an issue with the challenge. Let me get hold of support ...

Steve.

joe Bell Fenner
joe Bell Fenner
Courses Plus Student 2,646 Points

if you look at my previous reply I did type

let name = "Joe" the greeting is what I changed to try variants of syntax. I just left out, let name = "Joe" to keep the message/reply short.

Yep - I can see that you've solved the challenge correctly but highlighted that there's an issue with the Swift backend at the moment; I have advised Support.

Message from TTH Support:

*This is confirmed by our developers as a bug on our end, and we hope to have a fix by the end of the day. *

Jennifer Schultz yes, it was fixed the same evening. I hope you got going again; I assume you did as your comment has gone.