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?

// Enter your code below

lelet name = "Abdul"

let greeting = "Hi there"

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

1 Answer

Magnus Hållberg
Magnus Hållberg
16,952 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.