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

Matti Helenius
Matti Helenius
421 Points

Need help. Cant get to next lesson. SWIFT -coding beginner

I'm trying to do this lesson.

"Challenge Task 1 of 2

In this task we're going to declare two strings. First, declare a constant named name and assign to it a String containing your name.

Second, declare a constant named greeting. Set the value of greeting to an interpolated string that combines "Hi there, " with the string stored in the name constant.

As an example, the final value of greeting could be "Hi there, Linda"."

My code;

let name = "Matti"

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

It works in Xcode but it does not work on the coding test. I cannot get forward. Anyone can help?

It says "Bummer! Make sure the value you are assigning to greeting is an interpolated string" Help, Anyone?

I keep getting this error message "Make sure the value you are assigning to greeting is an interpolated string" not sure what i am doing wrong. Below is what i am writing

let name = Neel let greeting = Hi there let interpolatedGreeting = "(greeting) (name)"

3 Answers

Katherine Ebel
Katherine Ebel
43,799 Points

From the way you wrote your code in the question it looks like you just didn't interpolate the string correctly.

From the swift programming language book...

let multiplier = 3
let message = "\(multiplier) times 2.5 is \(Double(multiplier) * 2.5)"
// message is "3 times 2.5 is 7.5"
Matti Helenius
Matti Helenius
421 Points

Awsome thanks! It helped. :)

Matti Helenius
Matti Helenius
421 Points

Hi Neal,

I see you're having same problem as me. You need to put \ -before variables. I think you can't use the nterpolatedGreeting since it says in on the lesson so try but them on the greeting variable. Like this;

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

PS. put ``` -before and after you're code so it makes a box on the code and marks it clearly as an code.

See more on the "Reference this Markdown Cheatssheet for syntax examples for formatting your post - just up from the "Post Answer" button!

Benjamin Taylor
PLUS
Benjamin Taylor
Courses Plus Student 2,379 Points

None of these ansswer are working. Not sure what I am missing. My answer works just fine on xcode.

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

let name = "Ben"

let greeting = "Hi there,"

let interpolated = "(greeting) (name)"

For some reason the forward slashes arent showing in this, but they are there in my code.

not sure whats up. Please help

Swift 3 Basics - Challenge Task 1 of 2

Katherine Ebel
Katherine Ebel
43,799 Points

Hey Ben, Sorry later response but just in case... your greeting constant as you have it, is not interpolated. You just have a string literal. Greeting could be "Hi there, \(name)" for it to be "interpolated"