Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Valeria Ruiz
948 Pointsconcatenation mistake or bug?
I am doing Swift 2.0 Basics and I am learning about concatenation. I have tried everything I have learned so far for this method and still I can't get it right. The error message I get ays to make sure I am using concatenation, which I am.
Could someone please help me in finding out how I could concatenate better? My code is below
// Enter your code below
let name = "Valeria"
let hi = "Hi"
let there = "there"
let greeting = "\(hi) \(there), \(name)."
let stringLiteral = "How are you?"
let finalGreeting = "\(greeting) \(stringLiteral)"
2 Answers

Steve Hunter
57,696 PointsHi Valeria,
Concatention is adding the strings together using the plus sign. What you've done there is interpolation.
So, finalGreeting
should be made up of greeting
+ " How are you".
Something like this should get you through the challenge:
// Enter your code below
let name = "Steve"
let greeting = "Hi there, \(name)"
let finalGreeting = greeting + " How are you?"
You start with name
holding your name, then interpolate that into the greeting
constant. Next, you concatenate greeting
with the additional string " How are you?" by adding them together using the + operator.
I hope that helps,
Steve.

Valeria Ruiz
948 Pointsthanks so much guys!

Steve Hunter
57,696 PointsNo problem!
Martin Wildfeuer
Courses Plus Student 11,071 PointsMartin Wildfeuer
Courses Plus Student 11,071 PointsBeat me on that ;) One thing worth mentioning is that, just like in Steves solution, you really only have to wrap dynamic parts (like variables) of the string in
\()
when using string interpolation. All static parts are just like regular strings. See Apple docs.Steve Hunter
57,696 PointsSteve Hunter
57,696 Points