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

can't move forward in the course

not sure what is wrong in the code. seems to work in my platform.

let name = "Norlan" let interpolationGreeting = "("Hi there"), (name)"

strings.swift
// Enter your code below

let name = "Norlan"
let interpolationGreeting = "\("Hi there"), \(name)"

Try using single quotes for Hi there

Cynthia, single quotes will not work. You'll get a syntax error. Norlan's current code actually does work as-is, but just because it works doesn't mean it's right :smile:. There's no reason to interpolate a string literal into a string - it already is one!

4 Answers

Hi Norlan,

You only need the \() syntax to include variables/constants or calculated values. You shouldn't put the actual string part in parens:

interpolation.swift
// Enter your code below

let name = "Norlan"
let interpolationGreeting = "Hi there, \(name)"

I recommend re-watching this video about string interpolation earlier in the course.

You don't need to encapsulate the "Hi there, " as this is part of the string only encapsulate the name like so:

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

You don't need to interpolate "Hello, there". You also need to assign the String to a constant called greeting (not interpolationGreeting), and you need to put a "." at the end.

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

I hope this helps!

Thank you everyone.

You're welcome! (:

:thumbsup: