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 trialBilly Potts
Courses Plus Student 2,344 PointsI'm trying to declare to constants one with name and one which is interpolation and i don't know what I'm doing wrong
i tried let name = "Billy" let greeting = "Hi there," let interpolatedGreeting = "(Hi there,) (name)."
nothing is working
// Enter your code below
let name = "Billy"
let greeting = "\(Hi there,) \(name)."
3 Answers
Tobias Helmrich
31,603 PointsHey Billy,
you almost got it right! Just note that you only have to interpolate variables/constants but you're trying to interpolate the String itself ("Hi there, ") which you don't have to.
This should work:
// Enter your code below
let name = "Billy"
let greeting = "Hi there, \(name)."
I hope that helps, good luck! :)
David Bath
25,940 PointsYou only need to interpolate name.
let greeting = "Hi there, \(name)."
See what's going on? The greeting is a string, but by wrapping the constant name in ( ) Swift uses the value of that constant, even though it's between the quotation marks.
Billy Potts
Courses Plus Student 2,344 PointsThanks for the help Guys Got it