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

Why is this wrong?

let name = β€œking"
let greeting = "Hi there,"
let interpolatedGreeting = "\(greeting) \(name)."

Still new to this but i don’t understand what I’m missing.

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

Although what you are doing is correct and you obviously understood how string interpolation works, the assignment is a bit different:

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

That is, the string interpolation has to be assigned to the greeting constant directly, instead of combining greeting and name in a new constant.

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

Make sure you follow the instructions precisely, code checks on Treehouse are very strict (for good reason).

You will still get a compilation error, though:

// Make sure you are using the correct quote char
let name = β€œking"

// ""
let name = "king"

Hope that helps!