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

Scott Becker
Scott Becker
20,349 Points

Bummer! Make sure the value you are assigning to greeting is an interpolated string

Works in Xcode preview, but can't get past this in the code challenge?

strings.swift
// Enter your code below
let name = "Scott Becker."
let greeting = "Hi there"
let interpolatedGreeting = "\(greeting), \(name)"

4 Answers

Hi Scott,

You've done task 1 correctly. The second task wants an interpolated string saying "Hi there, name" - you need to merge the task one constant into that.

The last part wants a constant called finalGreeting - you've called yours differently - and it should be a concatenation of greeting and a string, "How are you?" (Ignore the leading space - that's a little error!).

You end up with:

let name = "Steve"
let greeting = "Hi there, \(name)"
let finalGreeting = greeting + "How are you?"

Make sense?

Steve.

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

It's expected to be in this form. What you're doing wrong is that you need to let greeting equal "Hi there, Scott Becker." Not interpolatedGreeting = If you read the instructions very carefully, you'll see that's what it says.

Scott Becker
Scott Becker
20,349 Points

that might be a step after the challenge I was taking, as I don't remember that string being gone over - let finalGreeting = greeting +

But I'll poke around some more to see if I can GET to that step :-)

Thanks!

Hi Scott,

Top right of this window is the "View challenge" button - this takes you to the challenge the forum post was made from. That's where I got this from, anyway.

This one: https://teamtreehouse.com/library/swift-20-basics/swift-types/string-manipulation

Either way, I hope you get it sorted - if not, just shout!

Steve.

Scott Becker
Scott Becker
20,349 Points

Thanks Samrat. I'm getting used to the semantics of designing with language as opposed to pixels. I appreciate all the help!