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

Abdul Fawaz
Abdul Fawaz
115 Points

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

why is the code above not considered as an interpolated string? when i types the same code on Xcode it ran it perfectly right and it even showed the results that i am supposed to get and in treehouse it my code is not accepted, may i please know why and how can i fix this?

strings.swift
// Enter your code below

lelet name = "Abdul"

let greeting = "Hi there"

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

1 Answer

Magnus Hållberg
Magnus Hållberg
17,232 Points

The main reason you get an error is that the challenge in the second part asks you to use concatenation, not string interpolation. These challenges are also specific regarding variables and constant names, they have to match the challenge specifications. Yous doesn't, the last constant are supposed to have the name finalGreeting. You named it interpolatedGreeting witch I suppose is good but not according to challenge specifications. A correct result is not always enough, that's because they want you to understand that there are different ways of doing things.