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 Basics Swift Types String Manipulation

Joshua McManus
Joshua McManus
1,998 Points

error "Make sure you are assigning the correct string to the variable" but there are no variables, just constants

Not sure what I'm doing wrong here. It's telling my the string isn't assigned to the correct variable, but the problem is only asking for two constants, no variables.

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

1 Answer

Hi Joshua,

You are correct, there are only constants, not variables. Use the word constant in place as the error is then correct.

You're trying to insert your name value, stored in the constant name inside the string, "Hi there,". You have correctly identified that a slash and brackets will help with this.

However, you just use them once, in the place where you want the value held by name inserting. So, you start with the string "Hi there," and then you want to insert the name value just there. That would look like:

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

I hope that helps - shout back if not!

Steve.