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 don't get this one....

What is now wrong in here?

strings.swift
// Enter your code below

let name = "Lucas" 
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting) How are you?"

3 Answers

Hannah Gaskins
Hannah Gaskins
14,572 Points

Hey there Lucas,

You are super close. The key is in the question description when it says "concatenate" think the + sign. And concatenate two separate strings. So you'll also want to close the (greeting) interpolation string and begin another. Check out this resource:

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/StringsAndCharacters.html

The final exercise will look like this:

let finalGreeting = "\(greeting)." + "How are you?"

Hope this helps!

Since greeting is constant that contains a string it does not need placed into a string or a backslash. Also notice the white space before 'How'.

let finalGreeting = (greeting) + " How are you?"
Taylor Amsler
Taylor Amsler
4,427 Points

Hey there. Super close, as that would work, but the challenge asks you to use string concatenation. So try something similar to:

let finalGreeting = "value1" + "value2" 

Hope that is helpful.