Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift 2.0 Basics Swift Types String Manipulation

Nate Drexler
Nate Drexler
1,883 Points

I'm stuck on this code challenge. See code below:

I thought I formatted the interpolation correctly

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

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

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,692 Points

Hey Nate,

There are a couple issues going on here.

  • You can not interpolate a string. Only variables / constants can be interpolated, so "Hi There," should not be enclosed in parenthesis.

  • The period needed cannot be added inside of a interpolated variable. You can add this two ways: After the closing parenthesis for the name variable but before the closing quote. Or just add in to the end of the value assigned to the name variable (I chose the latter).

Other than that... looks good. Below is the corrected code for you to reference. I hope it makes sense.

let name = "Nate Drexler." 

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

:dizzy:

Nate Drexler
Nate Drexler
1,883 Points

Thank you much, Jason. Makes perfect sense.

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,485 Points

let name = "Linda" let hello = "Hi there" let greeting = "(hello), (name)."