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

Not sure what I am doing wrong here to concantenate these to say: "Hi there, Cara. How are you?"

Concantenation lesson

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

Hi! I think I might be able to help. Im still a beginner too, so I may be wrong. However, what I think you're missing is that the code you have written is not concatenated. It is written using String Interpolation. Concatenated, I believe, should be similar to this: let name = "Cara" let greeting = "Hi there, " + name let finalGreeting = greeting + "How are you?"

I hope this works!

Steven Deutsch
Steven Deutsch
21,046 Points

Spot on Karl! Remember the proper spacing for the finalGreeting though. :)

2 Answers

Steven Deutsch
Steven Deutsch
21,046 Points

Hey caraembry,

Your code is technically correct. You just aren't coming about the solution in the way that the challenge wants you to. You are using String Interpolation to create the finalGreeting when you need to be using String Concatenation.

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

Good Luck

Ahhhh that was it haha. Thanks everyone!