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

Keeps saying I need to set greeting as an interpolated string but don't I first need to assign it a let value?

Keeps saying I need to set greeting as an interpolated string but don't I first need to assign it a let value?

strings.swift
// Enter your code below

let name = "Andrew"
let greeting = "Hi there"

let interpolatedGreeting = "\(greeting) \(name)"
Aryaman Dhingra
Aryaman Dhingra
3,536 Points

I think the only problem is that you need to put a comma after the greeting.

let interpolatedGreeting = "\(greeting), \(name)"

1 Answer

Sarah Hurtgen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Sarah Hurtgen
Treehouse Project Reviewer

Hi! The method you are using is technically accurate in the sense that yes, it works! But for the code challenges they need you to follow the directions in a very specific way for it to pass correctly. For this challenge, they want you to assign the full interpolated sentence to the constant "greeting", and the code you have listed is assigning the whole sentence to "interpolatedGreeting".

I believe they're wanting to draw attention to the fact that you can take a regular string, and then input a value into that string.

For example:

let example = "here is an example"
let fullSentence = "If you need some help, \(example)"
// would read "If you need some help, here is an example"

So if you take what you have right now for 'greeting' and add your '\ (name)' call into it's initial definition, you should have what they're looking for. Hope that helps!