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

David Hutton
David Hutton
126 Points

I don't understand what i am doing wrong, I am trying to do an interpolated greeting code, and it won't work.

below is what i typed:

let name = "billy bob"

let greeting = "Hi there ,"

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

i followed the video to perfection i thought...but I'm missing something but i don't know what.

strings.swift
// Enter your code below

let name = "David Hutton"

let greeting = "Hi there ,"

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

2 Answers

Antonio Montalvo
Antonio Montalvo
10,549 Points

let interpolatedGreeting = "(greeting) (name)"

No coma after greeting in: let interpolatedGreeting = "(greeting), (name)"

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey David,

For the first task, you've seemed to take it a bit farther and made it more complicated than what the challenge is asking for. Basically, it wants you to create a constant with your name as the value, which you've done correctly. Then it wants you to use string interpolation assigned to the constant greeting and using the constant that has your name, create the output "Hi there, David Hutton."

So, you're kind of on the right track, but you're greeting variable is not producing the right out come. You need to interpolate your name constant into the said constant.

You have to delete the constant interpolatedGreeting that you created and introduce that into the greeting variable:

// Enter your code below

let name = "David Hutton"

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

Hope that makes sense. Keep coding! :dizzy: