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

Eric Fox
Eric Fox
2,274 Points

Very confused as to why my linking of "how are you" after my greeting constant does not work in this situation?

Can someone tell me what is wrong with this code? It works fine in the compiler...

strings.swift
// Enter your code below
let name = "Eric"
let greeting = "Hi there, \(name)."
let finalGreeting "\(greeting) how are you?"

2 Answers

andren
andren
28,558 Points

There are two issues:

  1. In the code in your post you have forgotten the = sign in the last line.

  2. The challenge specifically asks you to use string concatenation for the third task, string concatenation is a technique where you use the + operator to combine separate string together. The technique you are currently using is called string interpolation. String concatenation and string interpolation are two different techniques that results in the same thing. So visually the result won't be any different, but for the purposes of this task you have to use string concatenation for the code to pass.

So instead of placing greeting inside the string you have to use + to combine it with " How are you?" like this:

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