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

How to say something in a concatenated string after a constant.

I don't understand why the editor is saying my code is wrong even when Xcode says I did it right. How does the treehouse editor want me to use a concatenated string.

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

The way you are doing it finalGreeting prints as "Hi there, Ben.. How are you?" (note the extra dot after Ben). I would guess that the editor sees that as an error. Try doing...

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

See if it works. Try to output the greeting with the same format as the instructions.

1 Answer

Hi Ben,

This:

"\(var) is interpolation"

And this:

var + " is concatenation"

Make sense?

Steve.