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 trialcurtis barton
609 Pointsinterpolated string
how do you assign to an interpolated string
// Enter your code below
let name = "curtis"
let greeting = "Hi, there"
let interpolatedGreeting = "\(Hi, there) \(name)"
3 Answers
Milos Ribera
9,633 PointsCurtis, I'm sorry I just saw your code and I tried to fix it. Now I checked the Challange.
Into the first step, you have to create a "name" constant of type string, and a "greeting" constant which contains a string and interpolates "name".
let name = "YourName"
let greeting = "Hi there, \(name)"
With interpolating you can easily concatenate strings, but you have to use the variable name instead of its value.
I hope it will be helpful for you
Wouter Willebrands
iOS Development with Swift Techdegree Graduate 13,121 PointsHi Curtis,
The first challenge asks you to create two constants. One named name in which you provide your name and a second called greeting that uses the first to create a greeting using interpolation.
let name = "your name" let greeting = "Hi there, (name)"
The answer Milo provided, while correct code, is likely not satisfying the compiler because it provides a solution using 3 properties.
The second part of the challenge asks you to create a constant named finalGreeting. If you are stuck on that part, this is probably why the solution provided is not working, as the compiler for the code challenges is very picky when it comes to naming properties.
Happy coding!
Milos Ribera
9,633 PointsHi Curtis! You were close!
You just have to interpolate greeting
, instead of its value "Hi, there"
It should have to be like this:
// Enter your code below
let name = "curtis"
let greeting = "Hi, there"
let interpolatedGreeting = "\(greeting) \(name)"
Hope it will be useful
curtis barton
609 Pointsim not sure why but it still seams to not be working