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

Steven Matthews
Steven Matthews
186 Points

interpolation

hello,

I am stuck on the first interpolation question, my answer states:

let name = "Steve Matthews"

let greeting = "Hi there, " + name

please help

strings.swift
// Enter your code below
let name = "Steve Matthews"
let greeting = "Hi there, " + name

2 Answers

Eli Flores
seal-mask
.a{fill-rule:evenodd;}techdegree
Eli Flores
iOS Development Techdegree Student 3,851 Points

// LETS DO SOME SAMPLE: let name = "Jhon Doe"

STRING CONCATENATION:
let greeting = "Hi there, " + name // heavily uses the plus sign => " + "

STRING INTERPOLATION: let greeting = "Hi there, (name)" // Uses " ONE SET OF DOUBLE QUOTATION!", No need for the plus sign, "+" // but uses a special syntax ==> () <== // store the given properties either let or var between the parenthesis => (name)

Paul Karim
Paul Karim
3,428 Points

Hey Steven, so what you're doing is actually called String concatenation. The challenge requires string interpolation.

So you would do something like this

let name = "Paul Karim" let greeting = "Hi there, (name)."

In front of (name) you need a backslash :) but that's it.

Steven Matthews
Steven Matthews
186 Points

Thank you for your help. I tried entering the code the way you typed it with the back slash but it still didn't work.

Steven Matthews
Steven Matthews
186 Points

never mind, I figured out what I was doing wrong, thanks again.