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

interpolated string

Hi everyone, I am trying to solve a quiz from Swift Basics and am puzzled as to my code is not being accepted.

The question is to declare two strings. name greeting

and set a value of greeting to an interpolated string that combines the string value from both name and greeting. When I write the code in quiz area, it does not work, when I write the same code in xcode playground, it works perfectly. I don`t understand what is wrong in my code...hope to get some hint about this...thanks. Cheers.

strings.swift
// Enter your code below

let name = "Dildar"
let greeting = "Hi there"

// String Interpolation

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

8 Answers

Nico Schmidt
Nico Schmidt
12,781 Points

That should do.

// Enter your code below

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

Concatenation is used in the second part of the challenge.

Nico Schmidt
Nico Schmidt
12,781 Points

I can give you some hints.

The challenge asks for concatenation and not interpolation.

By the way i would name the last constant finalGreeting, to be on the save side.

It should now be easy for you to solve.

Thank you Nico Schmidt I will try again :)

I have just tried it again with concatenation and it still doesnt work. I have tried several options and cant find the solution...

By the way, it is mentioned in the challenge to set the value of greeting to an interpolated string that combines the value of greeting and name...so I am not sure how it should be written...any other hints?? Thanks

wow...that was awesome! Thank you so much for your help Nice :) I am new to programming and very excited about learning all I can. This one was a little tricky, I think I did not understand the question properly. Now I get the question as well. Thank you again for your help. Awesome! Cheers.

Nico Schmidt
Nico Schmidt
12,781 Points

Thats great. Keep it up ;)

Thanks again. And sorry for the misspelling your name. I meant Nico :)

Hi again Nico, Next question is:

Declare a constant named finalGreeting, and concatenate the value of greeting with the string literal " How are you?".

I am trying it write it like this: let finalGreeting = "(greeting). How are you?"

and abviously it is not working :) Just curious what am I doing wrong? I tried other options as well...

Nico Schmidt
Nico Schmidt
12,781 Points

Your task is to concatenate.

// Enter your code below

let name = "Dildar"
let greeting = "Hi there, \(name)"
// String Interpolation

let finalGreeting = greeting + ". How are you?"

Amazing. That was not taught during the lessons or maybe I did not notice :) Thank you again for your prompt response, very much appreciated.

Cheers