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

DONT KNOW HOW TO DO THIS

I VE TRIED DIFFERENT VARIATION OF HOW TO DO THIS, CAN SOMEONE JUST SOLVE IT FOR ME? MY CODE WAS:

let name = "Taran" let interpolatedGreeting = "(Hi there,) (name)"

THANK YOU

2 Answers

andren
andren
28,558 Points

The solution is this:

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

It is worth noting that when you are doing challenges you have to name variables exactly what the challenge asks for. So by naming your variable interpolatedGreeting rather than just greeting, you would have failed the challenge even if the string interpolation code itself was correct.

Nicholas Richardson
Nicholas Richardson
4,867 Points

Great tip I know the first few code challenges I named my variables different and it took me a bit to realize that they really need to be named exactly as specified in the instructions!

While not a real world constraint, Treehouse does want you to name the variables as and how it appears in the question. So if you name it any different it will deem your answer incorrect.

While it may not always be the convention, for most of the questions it is.