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

I coded this quiz exactly as instructed. Quiz won't let me pass. Why these errors?

// My Code

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

//The Errors

swift_lint.swift:6:22: error: expected ',' separator let greeting = "(Hi there,), (name)" ^ , swift_lint.swift:6:28: error: expected expression in list of expressions let greeting = "(Hi there,), (name)" ^ swift_lint.swift:6:19: error: use of unresolved identifier 'Hi' let greeting = "(Hi there,), (name)" ^ swift_lint.swift:6:22: error: use of unresolved identifier 'there' let greeting = "(Hi there,), (name)" ^

strings.swift
// My Code
let name = "jay"
let greeting = "\(Hi there,), \(name)"

4 Answers

It looks like you where close.

The Hi there, did not need "/()" Interpolation string

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

Hi Damian, I recommend to watch the video about string interpolation again so that you understand the use of this concept.

It is used to be able to add the value stored in a variable to a string. "Hi there," is the string and 'name' is your variable. What does this mean? You only need to interpolate the variable in your string. Understand?

Thank you both for your quick responses!

Being a newb, and watching the lesson a second time, I see what caused the problem: The videos in this section only show concatenation used alone and interpolation used alone. It doesn't show the usage of both simultaneously, so being that I was on the second video (interpolation), I used the interpolation method shown in that video, which was two comma-separated constants within parentheses surrounded by quotes. I thought the string literal would also need to be inside the parenthesis.

Team TreeHouse ––– For newbs (like me), throw a hint in there that we don't need to wrap the string part of the expression within parentheses when assigning strings and constants simultaneously into values for another variable or constant. That would be awesome!

No problem! I also had the same issue with the quiz!