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

Daniel Branca
Daniel Branca
992 Points

Potential treehouse error

I think there is a mistake. The code worked and looked fine in XCode but when I copied it over it wasn't correct.

strings.swift
// Enter your code below

let name = "Daniel Branca"
let greeting = "Hi there,"

let interpolatedGreeting = "\(greeting) \(name)"

2 Answers

Bruce Röttgers
Bruce Röttgers
18,211 Points

Hey,

you're only supposed to declare 2 constants.

You should use string interpolation in the greeting constant.

Hope that helps, but don't hesitate to ask if there is something unclear. Bruce.

Daniel Branca
Daniel Branca
992 Points

thanks for the response!

Hmm sorry I dont know what you mean. I thought I was to declare the name at the greeting and put them together in the a string?

Bruce Röttgers
Bruce Röttgers
18,211 Points

Yes, but you're actually supposed to put them together in the greeting variable.

--> let greeting = "Hi there, (name)"

Daniel Branca
Daniel Branca
992 Points

ahhh makes sense.

So the way I had works, but that just wasn't the task, correct?

Thanks dude!

Bruce Röttgers
Bruce Röttgers
18,211 Points

Yes, you over complicated it a bit.

Don't forget to mark answers to your question as correct.

That helps other people see that your question has been answered and other students find answers for questions that may have already been answered.

:)