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

Adriana Chung
Adriana Chung
724 Points

what's wrong with my code?

Hi, I have no idea what is wrong with my code! And it's just two lines. lol

let name = "Maru" let greeting = "Hi there, " + name + "."

I can't pass the challenge task and it keeps saying something like "Make sure the values you assign to greeting is a interpolated string".

1 Answer

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Hi there.

What you did here isn't wrong, and it yields the same result. However, this challenge asks that you inject the constant name into the String using string interpolation.

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.

let greeting = "Hi there, \(name)."
Adriana Chung
Adriana Chung
724 Points

Hi William,

Thanks for your help! :)