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

Test Error

I tried that code in the test and i followed all the rules related to the previous video, but the compiler doesnt work and i dont know how to do it.

strings.swift
// Enter your code below
let name = "Andrei"
let greeting = "\(Hi) \(there) \(name)"

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! At around 1:45 of this video the instructor explains how to use string interpolation. In the instructions, it is stated that the thing inside the parentheses is the name of a variable or constant. However, you've put Hi and there inside something to be interpolated. Neither of those is variables or constants.

Secondly, the string should contain a comma but is missing this. Finally, the challenge explicitly asks for the string assigned to the constant greeting to end with a full stop . Take a look:

// Enter your code below
let name = "Andrei"
let greeting = "Hi there, \(name)."

This will make a constant called name and assign "Andrei" to it. Then we make a constant named greeting and assign it the string literal "Hi there," along with the interpolated variable/constant name. The end result is that greeting will contain "Hi there, Andrei."

Hope this helps! :sparkles:

Thanks so much!