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 trialAbdijabar Mohamed
1,462 PointsBug in my code?
Hello anyone out there. Below is my code to do an interpolation that returns Hi there, Abdi. But I get an error and could not correct it. Please help Thanks
let name = "Abdi" let greeting = "(Hi there),(name)."
2 Answers
Dave Ko
11,915 PointsYour almost there, just need to make a few small changes.
String interpolation is a way to construct a new String value from a mix of constants, variables, literals, and expressions by including their values inside a string literal. Each item that you insert into the string literal is wrapped in a pair of parentheses, prefixed by a backslash
So, your going to use string interpolation on the 2nd let.
let name = "Abdi"
let greeting = "Hi there \(name)."
Abdijabar Mohamed
1,462 PointsThanks Dave Ko. I was confused about the 2 full stops but one was for the normal sentence used by the author and now I know that I don't need interpolation to write a string that I can just put in the " ". Thanks Dave