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

Hunter Hayes
Hunter Hayes
1,415 Points

When I set my greeting as an interpolated string it gives me errors about the "Hi there,". How should I fix this?

What should I do to the interpolated string to fix this?

strings.swift
// Enter your code below

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

1 Answer

Dan Hillman
Dan Hillman
4,394 Points

"Hi there," does not need to be interpolated because it is not a variable or constant, it is just a string. When you interpolate a variable or constant with the back slash parentheses syntax, you are referencing the value within the variable or constant.

So, your code should look like this:

//Enter your code below

let name = "Hunter"
let greeting = "Hi there, \(name)."
Hunter Hayes
Hunter Hayes
1,415 Points

Thank you for your help. I appreciate it! I was a little confused on interpolated strings at first but I am starting to get the hang of it now.