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'm stuck, I have to concatenate. And i forgot how it works..

// I already have this constant.

let greeting = "Hi there, (name)"

// but now it wants me to declare a new constant named "finalGreeting" with the the "greeting" constant, and add a new string. I did this -

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

// and it tells me "Bummer! - Make sure you're using concatenate"

//Please help me, maybe this might be easy, but i'm completely lost :)

strings.swift
// Enter your code below
let name = "Sebastian"
let greeting = "Hi there, \(name)"
let finalGreeting = "\(greeting) How are you?"

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Try and remember it this way. The strange combination of backslash and parentheses... that's interpolation. Concatenation... that's just a plus sign :) Take a look at the line you need and see how close you actually were!

let finalGreeting = greeting + "How are you?"

Thank you Jennifer :)