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