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

It says not assigning "greeting" to an interpolated string let greeting = "\("Hi there") \(name)\(".")" works in Xcode

What am i missing

strings.swift
// Enter your code below
let name = "Joe"

let greeting = "\("Hi there,") \(name)\(".")"
Reed Carson
Reed Carson
8,306 Points

just a comment. I think this is the #1 question I see about iOS here, this very example, and everyone basically does this same thing more or less.

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Josef,

I'm actually very surprised that this would actually work in Xcode.

First you can't interpolate a string... only variables can be interpolated. And it seems like you may be trying to mix interpolation with concatenation. For Interpolation, you only use 1 opening quotation mark and 1 closing quotation mark. The strings are just a normal string inside, and then you add the interpolated variables as needed.

Below is the correct code for your reference. I hope it'll make sense. If you're not 100%, I recommend that you review String Interpolation before moving on, as it is a very integral part of the upcoming lessons.

let name = "Joe"
let greeting = "Hi there, \(name)."

Keep Coding! :)

:dizzy:

Thank you, i understand now.