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

Mus A
Mus A
419 Points

I don't see whats wrong with my code?

let name = "mus"

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

let finalGreeting = "(greeting) How are you?"

strings.swift
let name = "mus"

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

let finalGreeting = "\(greeting) How are you?"

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! While your code would generate the same results, it does not meet the requirements of the challenge. The challenge explicitly asks you to use concatenation instead of interpolation for the last part. Concatenation is the use of the + sign to add two strings together. Interpolation is the use of the backslash and parentheses for inserting the value of a variable into a string.

Take a look at an example:

let string1 = "This is the first string."
let string2 = "This is the second string."

// concatenation
let wholeString = string1 + string2

// interpolation

let wholeString2 = "\(string1) \(string2)"

I believe the point of this challenge is to make sure you can use either method to achieve similar results. You can never have too many tools in your tool belt!

I believe you can get it with these hints, but let me know if you're still stuck! :sparkles: